-
Notifications
You must be signed in to change notification settings - Fork 51
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
Support explicitly naming constraints #100
base: main
Are you sure you want to change the base?
Conversation
The CI complains in a step of the migrations on Rails 5.0, 5.1: ArgumentError: Unknown migration version "5.2"; expected one of "4.2", "5.0", "5.1" |
Sorry, that was an auto-generated migration file that slipped through. |
@andrewclink Perhaps all that remains is a rebase (to get rid of conflicts)? |
@andrewclink Perhaps you can rebase and resolve conflicts? |
Sure, I actually have a few free hours today! Let me take a look. |
This allows setting of `upsert_keys` and `upsert_options` directly when calling `#upsert` or `.upsert`. This will overwrite the default `upsert_keys` and `upsert_options` set in the model.
…upsert into on_constraint
This PR allows one to pass an explicit Postgres constraint name to
upsert_keys
:This generates SQL like
My only question is the proper quoting of the constraint name. On one hand, I wouldn't expect a dev to SQL-inject themselves. An attacker already having access to ActiveRecord::Base class methods probably obviates the need to be concerned with security. However, I'm raising it now if anyone else thinks it needs to be addressed.
Tests included (which requires migrating your test database). All are passing ✅