-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeQL syntax updates #383
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
|
flyingsilverfin
approved these changes
Dec 17, 2024
flyingsilverfin
added a commit
to typedb/typedb
that referenced
this pull request
Dec 19, 2024
## Release notes: product changes We mirror the changes from typedb/typeql#383, which is composed of 3 changes: 1) We now require that all assignments are preceded with a `let` keyword: ``` match $p isa person, has monthly-salary $monthly; let $annual_salary = $monthly * 12; ``` 2) We rename `long` to `integer`, to use a more familiar term for integer values (`long` is very c-like!) ``` define attribute age, value integer; ``` This is still defined as a 64-bit signed integer in TypeDB's backend. 3) We make a consistent constructor syntax for instances: ``` insert $p isa person; # create entity $f isa friendship (friend: $p); # create relation with players $a isa age 20; # create attribute with value ``` Previously, we would write this as: ``` insert $p isa person; $f (friend: $p) isa friendship; $a isa age; $a == 20; ``` Note that the _anonymous relation constructor_ is now allowed like this: ``` insert friendship (friend: $p) ; ``` instead of: ``` insert (friend: $p) isa friendship; ``` ## Motivation For 1), the `let` binding makes it clearer to users when a attribute value is a computed value within the query, and not being looked up from storage. For 2), we feel that the `integer` syntax will be clearer and more familiar to users of most programming languages. For 3), we resolve a long-standing inconsistency with giving newly-created attributes a value. We already had the following syntactic sugar for `has` clauses: `match $x isa person, has age 10;`. We make this syntactic sugar as the basis of a consistent form for creating entites, relations, and attributes. ## Implementation We update all tests using the above syntaxes, and update the translation phase to use the new TypeQL data structures. --------- Co-authored-by: joshua <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Usage and product changes
Adds
let
keyword before assignments & moves the constraint on anisa
to the end. E.g.$x isa marriage ($a, $b)