Skip to content
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

feat(core): allow fine-grained control over em.upsert() #4669

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

B4nan
Copy link
Member

@B4nan B4nan commented Aug 29, 2023

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 #4325
Closes #4602

@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Patch coverage is 99.17% of modified lines.

❗ Current head 76d493d differs from pull request most recent head c84c034. Consider uploading reports for the commit c84c034 to get more accurate results

Files Changed Coverage
packages/core/src/drivers/IDatabaseDriver.ts ø
packages/core/src/utils/upsert-utils.ts 94.44%
packages/core/src/EntityManager.ts 100.00%
...ckages/core/src/unit-of-work/ChangeSetPersister.ts 100.00%
packages/core/src/utils/index.ts 100.00%
packages/knex/src/AbstractSqlDriver.ts 100.00%
packages/mongodb/src/MongoConnection.ts 100.00%
packages/mongodb/src/MongoDriver.ts 100.00%

📢 Thoughts on this report? Let us know!.

@B4nan B4nan force-pushed the upsert-options branch 2 times, most recently from 47659db to 98083b9 Compare September 7, 2023 23:58
@B4nan B4nan marked this pull request as ready for review September 7, 2023 23:58
@B4nan B4nan force-pushed the upsert-options branch 2 times, most recently from 3503603 to 76d493d Compare September 8, 2023 18:51
Signed-off-by: Martin Adámek <banan23@gmail.com>
@B4nan B4nan merged commit ab0ddee into master Sep 8, 2023
9 checks passed
@B4nan B4nan deleted the upsert-options branch September 8, 2023 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant