-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Mutation
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
insert ... on conflict (<fields>) do update set x = <expression> is rejected because a single MongoDB update applies the same operators to both the insert path and the matched path of an upsert, so an assignment is translatable only when the expression evaluates, on the insert path, to exactly the value the insert would have written.
Some expressions have that property. set publishYear = publishYear + excluded.publishYear translates faithfully as a pipeline update, {$add: [{$ifNull: ["$publishYear", 0]}, <proposed value>]}, because 0 is the identity of + and the proposed value sits in the surviving operand; the result matches PostgreSQL on both the insert and the conflict path. The same construction for - negates the insert-path value.
The translator cannot classify an arbitrary expression tree, so support means whitelisting recognisable expression patterns and translating each to its identity-element pipeline form.
- related to
-
HIBERNATE-218 Translate HQL INSERT ... ON CONFLICT with a field-list target to an upsert
-
- Needs Triage
-