You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently, when using the entity manager's em.upsert or em.upsertMany functions to upsert data, all fields other than the unique ones are included in the update. However, sometimes we need to keep some of the fields as they are if the row already exists, but insert a new value for them if it doesn't.
Describe the solution you'd like
I would like to be able to specify which fields to exclude from the on conflict update clause. Maybewe can add an excludeFieldsOnUpdate option in the NativeInsertUpdateOptions which is an array of field names that should be kept as is if the row already exists, but inserted with new values if it doesn't.
Describe alternatives you've considered
Some alternatives are to use the query builder or a raw SQL query instead of the ORM's em.upsert or em.upsertMany functions, but it would be nice to have the option through the EntityManager.
Additional context
This is based on discussion #4317
The text was updated successfully, but these errors were encountered:
Have you worked on this yet? I'm also interested in this feature and will be able to work on this.
I 'm struggling to set up the repo and get it to run as I'm not very familiar with docker. Also currently busy with some other stuff. Feel free to work on it. I will probably try again in about a week
Adds 4 new options to `em.upsert()`:
- `onConflictFields?: (keyof T)[]` to control the conflict clause
- `onConflictAction?: 'ignore' | 'merge'` used ignore and merge as that
is how the QB methods are called
- `onConflictMergeFields?: (keyof T)[]` to control the merge clause
- `onConflictExcludeFields?: (keyof T)[]` to omit fields from the merge
clause
Closes#4325Closes#4602
Is your feature request related to a problem? Please describe.
Currently, when using the entity manager's
em.upsert
orem.upsertMany
functions to upsert data, all fields other than the unique ones are included in the update. However, sometimes we need to keep some of the fields as they are if the row already exists, but insert a new value for them if it doesn't.Describe the solution you'd like
I would like to be able to specify which fields to exclude from the on conflict update clause. Maybewe can add an
excludeFieldsOnUpdate
option in theNativeInsertUpdateOptions
which is an array of field names that should be kept as is if the row already exists, but inserted with new values if it doesn't.The proposed option looks like:
Describe alternatives you've considered
Some alternatives are to use the query builder or a raw SQL query instead of the ORM's
em.upsert
orem.upsertMany
functions, but it would be nice to have the option through the EntityManager.Additional context
This is based on discussion #4317
The text was updated successfully, but these errors were encountered: