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

Option for ignored columns on update #51

Conversation

aqeelvn
Copy link

@aqeelvn aqeelvn commented Jan 27, 2020

Closes #50

Alternately I also noticed #49 which also attempts to fix the same issue but the API interface is slightly different.
I could be wrong, but I'm guessing typically you may want to avoid only a small number of columns on UPDATE so rather than having to explicitly define all the columns it might be more convenient to just specify those columns that need to be ignored.
Also this interface would nicely allow for having convenient default values like created_at. I haven't added it though in this PR as that could potentially be a breaking change and may need a major version bump depending on what the maintainers think.

cc @jamis @mberlanda

@aqeelvn
Copy link
Author

aqeelvn commented Jan 27, 2020

The CI failure seems to be unrelated

@aqeelvn aqeelvn marked this pull request as ready for review January 27, 2020 16:42
Copy link
Collaborator

@mberlanda mberlanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me.
The test suite in travis is not reliable anymore since we have too many versions how reached the end of life and we are missing the most recent.

May I ask to to update also the .travis.yml removing 2.2, 2.3 and adding 2.6 and 2.7 before ruby-head?

Thank you very much

@@ -16,12 +16,14 @@ def initialize(connection, table_name, primary_key, column_names, set_size=500,
@ignore = ignore
@update_duplicates = update_duplicates
@return_primary_keys = return_primary_keys
@ignored_columns_on_update = Array.wrap(ignored_columns_on_update)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamis I am not sure if the gem is supposed to work only with a dependency on activerecord or it was designed to have a dependency on activesupport as well:

https://apidock.com/rails/Array/wrap/class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good spot. I don't think we need to keep this, and can use Array(ignored_columns..) as we are not expecting anything unusual in that param like a hash.

@aqeelvn aqeelvn force-pushed the option-for-ignored-columns-without-default branch from 9460dbe to d68520a Compare January 28, 2020 09:23
@aqeelvn
Copy link
Author

aqeelvn commented Jan 28, 2020

Thank you for taking a look @mberlanda, appreciate it. I've applied your suggestions. Could you take another look when you get a chance?

Copy link
Collaborator

@mberlanda mberlanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me.
The build is still not passing on travis against ruby-head
You may want to add something like:

allow_failures:
  - rvm: ruby-head

(I am not 100% sure that it would work straight away 😄 )

@aqeelvn aqeelvn force-pushed the option-for-ignored-columns-without-default branch from b6243db to fa25dd0 Compare January 28, 2020 10:56
@aqeelvn
Copy link
Author

aqeelvn commented Jan 28, 2020

@mberlanda Thank you. Have ignored ruby-head for now. Would you like an issue to track this bit and handle it later ?

@mberlanda
Copy link
Collaborator

I would wait for @jamis feedback before merging.

I was considering to go for a major bump dropping the support for ruby < 2.4 and rails < 5.
This should be done definitely in a separated pr

@aqeelvn
Copy link
Author

aqeelvn commented Mar 3, 2020

Hi @jamis , just wanted to quickly check if you had a chance to take a look at this one. Would appreciate any feedback you have.

@mberlanda
Copy link
Collaborator

@aqeelvn I hope you are doing great! Would you be available to re-submit your changes in a new revision of this PR rebasing on master?
I managed to make the test suite more resilient (testing against multiple ruby and rails version and different adapters). An adapter based design has been implemented for the query serialization.

Thank you very much for the time you spent on this contribution

@mberlanda
Copy link
Collaborator

hey @aqeelvn do you want me to cherry-pick your changes and adapt them to the new gem structure?

@aqeelvn
Copy link
Author

aqeelvn commented Feb 24, 2021

@mberlanda Hey, thanks for reaching out. Yes it would be good to get the changes one way or the other. I know @sikachu were trying to get my changes on the latest master few days ago. @sikachu are you still working on it?

If not it would be great if you can cherry-pick my changes as you suggested, sorry I'm going through a busy schedule lately.

@sikachu
Copy link

sikachu commented Mar 10, 2021

@aqeelvn I'm also focusing on something else right now so @mberlanda please feel free to work on this.

@aqeelvn aqeelvn closed this Jun 2, 2023
@aqeelvn aqeelvn deleted the option-for-ignored-columns-without-default branch June 2, 2023 17:18
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

Successfully merging this pull request may close these issues.

Update duplicates option currently updates all columns which may not be desirable
3 participants