DDC-668: add upsert support #821

Open
opened 2026-01-22 12:51:42 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Jul 4, 2010).

Originally assigned to: @Majkl578 on GitHub.

Jira issue originally created by user @lsmith77:

Didnt find anything in the docs on this. Is D2 capable of doing an UPSERT [1] in case I am trying to persist an object that may or may not have been saved previously. Different RDBMS support different syntax for this case. Like MySQL has INSERT .. ON DUPLICATE KEY UPDATE (or even INSERT IGNORE) while the SQL standard defines a MERGE syntax which seems to be gaining support. Of course you can always fallback to a SELECT FOR UPDATE (or if you want to be hacky an INSERT which catches duplicate key violations .. but probably not a good idea since many RDBMS rollback on a failure inside a transaction).

[1] http://en.wikipedia.org/wiki/Upsert

See also http://opensource.atlassian.com/projects/hibernate/browse/HHH-3011 asking for MERGE support

Ideally there would be a way to define on a model or model instance level if merge logic should be applied.

Originally created by @doctrinebot on GitHub (Jul 4, 2010). Originally assigned to: @Majkl578 on GitHub. Jira issue originally created by user @lsmith77: Didnt find anything in the docs on this. Is D2 capable of doing an UPSERT [1] in case I am trying to persist an object that may or may not have been saved previously. Different RDBMS support different syntax for this case. Like MySQL has INSERT .. ON DUPLICATE KEY UPDATE (or even INSERT IGNORE) while the SQL standard defines a MERGE syntax which seems to be gaining support. Of course you can always fallback to a SELECT FOR UPDATE (or if you want to be hacky an INSERT which catches duplicate key violations .. but probably not a good idea since many RDBMS rollback on a failure inside a transaction). [1] http://en.wikipedia.org/wiki/Upsert See also http://opensource.atlassian.com/projects/hibernate/browse/HHH-3011 asking for MERGE support Ideally there would be a way to define on a model or model instance level if merge logic should be applied.
admin added the New FeatureInvalid labels 2026-01-22 12:51:42 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#821