Skip to content

How to model external ids with ability to do upserts #5712

Answered by elprans
ssendev asked this question in Q&A
Discussion options

You must be logged in to vote

Using inheritance would be the way, as you need the constraints to be local to the object your upserting.

There are some limitations currently when it comes to unless conflict and constraint inheritance. In this case the issue is that you cannot use non-delegated constraints in insert Movie unless conflict else (update Movie ...), because the conflicting object could be any ExtStr or ExtInt, not just a Movie!

But if you don't need exclusivity across data types, then delegated constraints would work just fine, e.g:

type ExtSource {
  required url: str { constraint exclusive; }
}
abstract type Ext {
  ext_source: ExtSource;
}
type ExtInt extending Ext {
  ext_int: int64;
  delegated constra…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by ssendev
Comment options

You must be logged in to vote
1 reply
@elprans
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants