feat: EXPOSED-258 Enhance upsert to allow exclusion of columns set on conflict #2006
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, if the
onUpdate
parameter ofupsert()
is specified, this argument will be used in the update clause of the upsert statement. If the argument is leftnull
, a duplicate of the column-value assignments from the insertbody
block will be used instead.So if a user wants to only update a subset of columns, or not update columns with default values for examples, the only option is to provide an argument to
onUpdate
that duplicates the insert block:This can become verbose, so an additional parameter,
onUpdateExclude
, has been introduced, which duplicates all insert column-value pairs except those for the specified columns:This parameter could also be used in the reverse case when the number of columns to update is small but the user wants to avoid duplicating the insert values:
Next steps: