-
Notifications
You must be signed in to change notification settings - Fork 22k
Add defaults option to ActiveRecord::InsertAll. #35635
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
Conversation
0606107
to
0ee01ea
Compare
LGTM! 🙂 👍I like how you did this without a second loop through all the |
0ee01ea
to
3a3d15a
Compare
@boblail 👀 changes addressed. |
3a3d15a
to
05a8990
Compare
🤔 What if we didn't add Book.insert_all(data, defaults: { created_at: Time.now, updated_at: Time.now }) we used Book.create_with(created_at: Time.now, updated_at: Time.now).insert_all(data) The behavior will be slightly different. However, I think it accomplishes the same goal, adds fewer arguments to |
good idea @boblail |
After thinking about it more, I came to the same conclusion as @boblail that we shouldn't add E.g. Yes, we should also support Thanks! |
Rails 6 has hit its feature freeze, so there’s no further feature development scheduled for 6.0 |
mainly extracted from #35494
If same key is used in data hash and also in defaults, data hash one is used.
I'll update documentation once approved.