-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Mutation
-
3
-
None
-
None
-
None
-
None
-
None
-
None
-
None
insert ... on conflict do nothing with no conflict target means: insert, and silently skip any row that violates any unique constraint. That is not expressible as an upsert, there being no columns to build a filter from; it is a plain insert with duplicate-key suppression, executed unordered so non-colliding rows still land.
Translation: the insert command gains "ordered": false and a private "onDuplicateKey": "ignore" field. The command JSON is a contract between the translator and the JDBC adapter, not something forwarded to the server, so the private field never reaches mongod.
MongoStatement: honour ordered via BulkWriteOptions, consume onDuplicateKey and suppress write errors with code 11000 when it is set, take the affected count from the number of documents inserted, and widen the two assertions that currently assume ordered writes (getErrorCode's single-write-error assertion and calculateBatchUpdateCounts). Existing commands stay ordered and unaffected.
Verified against PostgreSQL: a single-row collision on any unique constraint is skipped with count 0, and a multi-row statement with one collision inserts the non-colliding rows and reports their count.
Builds on the conflict-clause dispatch of HIBERNATE-218.
- is depended on by
-
HIBERNATE-218 Translate HQL INSERT ... ON CONFLICT with a field-list target to an upsert
-
- Needs Triage
-