[FEATURE]: Unique Constraint in DQL #8408
Labels
area/querylang
Issues related to the query language specification and implementation.
community
Issue or PR created by the community.
kind/feature
Something completely new we should consider.
Have you tried Dgraph before this proposal? and did not find anything similar?
No response
What you wanted to do.
From the DQL level up, there should be a way to force uniqueness. For backwards compatibility this should be easy. Adding this to a node that already has duplicate values would not be allowed.
This simplest way todo this would be to have a @unique directive in the dql schema:
or with a composite index:
This should also be possible on a 'facet', but there would need to be a way to declare facet types in dql. Perhaps:
and for composite:
Note: In GraphQL, the unique directive would need the "field" input to be not break the GraphQL spec, here we can simplify it with just an array inside ().
What you actually did.
You can create this in GraphQL, but it is not enforced once added, and DQL is certainly not enforced. Composite indexes are also currently impossible.
Why wasn't it great, with examples.
We need better data integrity.
Additional information.
It should be 100% impossible to add any kind of duplicate data once this unique directive is activated.
Unique constraints should be nullable by default, but could be not null with the @NotNull directive.
This is how @akon-dey wants to implement this. First in DQL, then GraphQL.
Related to:
The text was updated successfully, but these errors were encountered: