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
hello there! I would like to perform a very basic operation: insert a record into the database and update it if there is a conflict on the ID.
I thought allow_user_specified_id could help, however, it didn't:
UnsupportedFeatureError: UNLESS CONFLICT can not use ELSE when constraint is from a parent type
I then tried to duplicate the ID property using overloaded, and add a constraint (both inside the property {} declaration OR separately like constraint exclusive on (.id), — nothing works.
I see no other option apart from creating and maintaining my own IDs for every object.
What am I doing wrong?
I'm ok with not specifying the IDs myself, however, I need to be able to do upserts without duplicating the objects by updating them by ID if they exist already.
The duplicating ID approach is also weird because you cannot just create a new abstract type with a property e.g. uid — it will not work again, because the constraint will be on the parent type, again 🙃
So it is gonna lead to tons of duplicated code (4 lines per each object type declaration, which is a lot)
The text was updated successfully, but these errors were encountered:
This issue is discussed in #4302
The crux of the issue is that if something conflicts with .id, it might come from a different type, not the one you care about. We haven't come to a firm conclusion what the best way to deal with this question is, though there are options.
Probably your best workaround now is to use the new 4.0 feature of using ?? with DML on the RHS.
hello there! I would like to perform a very basic operation: insert a record into the database and update it if there is a conflict on the ID.
I thought
allow_user_specified_id
could help, however, it didn't:I then tried to duplicate the ID property using
overloaded
, and add a constraint (both inside the property{}
declaration OR separately likeconstraint exclusive on (.id)
, — nothing works.I see no other option apart from creating and maintaining my own IDs for every object.
What am I doing wrong?
I'm ok with not specifying the IDs myself, however, I need to be able to do upserts without duplicating the objects by updating them by ID if they exist already.
The duplicating ID approach is also weird because you cannot just create a new abstract type with a property e.g.
uid
— it will not work again, because the constraint will be on the parent type, again 🙃So it is gonna lead to tons of duplicated code (4 lines per each object type declaration, which is a lot)
The text was updated successfully, but these errors were encountered: