-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
ActiveRecord#touch should accept multiple attributes #14423
ActiveRecord#touch should accept multiple attributes #14423
Conversation
I wrote an extra test too |
Mind explaining a use case for many attributes being updated? Thanks. |
this github page is a good example When you press "close & comment", |
raise ActiveRecordError, "cannot touch on a new record object" unless persisted? | ||
|
||
attributes = timestamp_attributes_for_update_in_model | ||
attributes << name if name | ||
attributes += names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use attributes.concat(names)
to avoid extra object allocation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we should do this only if we have any name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@egilburg I just bm'd it to 100_000_000 times,
the results show a 0.5 .. 1.3% performance improvement,
thanks for the tip 👍
Could you add a CHANGELOG entry? |
@yakko if we'd be getting into microoptimization, |
@rafaelfranca done |
Could you squash your commits? |
squashed it is |
photo.sealed_at # was updated | ||
|
||
*James Pinto* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last thing: this entry should be at the top. Thanks!
@rafaelfranca @carlosantoniodasilva the conditions were met and TravisCI has passed 👍 |
ActiveRecord#touch should accept multiple attributes Conflicts: activerecord/CHANGELOG.md
No description provided.