-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Introduce unique annotation #273
Introduce unique annotation #273
Conversation
PR Review ChecklistDo not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed. Trivial Change
Code
Architecture
|
| RELATES type ( AS type )? | ||
| PLAYS type_scoped ( AS type )? | ||
| VALUE value_type | ||
| REGEX STRING_ | ||
| TYPE label_any | ||
; | ||
|
||
annotations_owns : ( ANNOTATION_KEY )? ( ANNOTATION_UNIQUE )? ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krishnangovindraj raised good point about order indendence:
OWNS type ( AS type )? (annotation_owns*)
annotation_owns = ANNOTATION_KEY | ANNOTATION_UNIQUE | ANNOTATION_CARD ...
note that now each one is optional independently and the rule is written in singular form.
private final TypeVariable attributeType; | ||
private final TypeVariable overriddenAttributeType; | ||
private final boolean isKey; | ||
private final List<Annotation> annotations; | ||
private final Annotation uniqueness; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to group annotations into super-types of annotations in the language for validation/restriction purposes.
8c6290e
to
98014d3
Compare
564aa5f
to
8029783
Compare
8029783
to
ec17bdf
Compare
## What is the goal of this PR? We generalise the annotation syntax and parsing to be able to handle a new type of annotation: the `@unique` annotation, which is available only on the owns constraint: `define person sub entity, owns email @unique;` The `@unique` annotation has been introduced first in TypeQL Java in #273. ## What are the changes implemented in this PR? We update the pest grammar used in the Rust parser to mirror the changes in TypeQL Java, and adjust the parser visitors to match. A few drive-by fixes: - mild refactoring prompted by Clippy; - replaced usage of deprecated `chrono` `NaiveDateTime` builders with up-to-date variants.
What is the goal of this PR?
We generalise the annotation syntax and parsing to be able to handle a new type of annotation: the
@unique
annotation, which is available only on theowns
constraint:This annotation indicates that any
email
s a person owns must be unique to that person. It does not place any restrictions on the number of emails any given person may own.The language builder API has also been updated to use a generalised form of any number of annotations, rather than having a particular boolean per annotation type (now, pass annotation
UNIQUE
orKEY
instead of booleans).What are the changes implemented in this PR?
annotations_owns
in the grammarannotations
:@key
becomes anannotation
, as does the new@unique
annotations
in the grammar and the language builders