Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure attributes not to be updated (other than created_(at|on) #51

Open
jan opened this issue May 22, 2015 · 3 comments
Open

Configure attributes not to be updated (other than created_(at|on) #51

jan opened this issue May 22, 2015 · 3 comments

Comments

@jan
Copy link

jan commented May 22, 2015

Sometimes it makes sense not to update fields, but you still need to set them for new records. You are already doing this for created_(at|on). We have a use case for not updating an additional field.

This would be much easier to implement than different create_atts and update_atts like suggested in
#17 by passing an option and then using it in here:

  def update_column_definitions
    setter_column_definitions.select { |cd| cd.name !~ CREATED_COL_REGEX }
  end

Does that make sense? Would you integrate such a pull request into your gem?

@seamusabshere
Copy link
Owner

@jan definitely - i would love for there not to be a static set of cols

@pnomolos
Copy link
Collaborator

@jan @seamusabshere I think that something between these two options would be the most useful solution - something like

  • Upsert.batch(connection, table, separate_selector_and_setter: true) OR
  • Upsert.batch(connection, table, ignore_update_fields: %w[list of fields])

which would allow you to enable the functionality as-needed.

I would rather not use a constant (or class level variable) as that's going to cause issues with thread safety.

@samkahchiin
Copy link

samkahchiin commented Oct 27, 2018

@seamusabshere , is this feature available now? Can't find it in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants