active_record_upsert
active_record_upsert copied to clipboard
Upsert allowing keys to be excluded
This PR adds exclude:
to upsert_options
to allow one to leave certain attributes alone during an upsert. The use case is when a column is defined as NOT NULL DEFAULT "something"
and an attempt to insert NULL into that column is unwanted.
This includes minimal passing tests.
Ruby 2.3+ is required due to the safe navigation operator being used once. If that's undesirable, an explicit check for nil could be used instead.
This fixes #102
Regarding the 2.3, the CI only tests 2.4+. We should be good there.
@andrewclink Can you rebase your branch on the target branch?