typeql
typeql copied to clipboard
Discrepancies when parsing patterns containing a disjunction in Java
Description
Graql.parsePattern()
throws a syntax error when a disjunction is followed by a statement if the whole pattern isn't wrapped in {}
to indicate that it's a conjunction. It also accepts a disjunction without an outer scope of variables to bind to (although this may be expected if this validation has to be implemented subsequently).
Environment
- OS (where Grakn server runs): Mac OS 10
- Grakn version (and platform): Grakn Core 1.8
- Grakn client: client-java
Reproducible Steps
Steps to create the smallest reproducible scenario:
Pattern pattern = Graql.parsePattern("{$c isa company; { $c has name \"some-name\"; } or { $c has name \"the-company\"; }; };");
The above throws a syntax error. I believe this should not be the case as Graql should transparently understand this as a conjunction, without wrapping with {}
. The need for {}
is otherwise typically hidden from users.
Below, with the braces, works:
Pattern pattern = Graql.parsePattern("{$c isa company; { $c has name \"some-name\"; } or { $c has name \"the-company\"; }; };");
As does a disjunction without a statement outside, despite the fact that this will/should later fail validation as it lacks a variable scope outside of the disjunction.
Pattern pattern = Graql.parsePattern("{ $c has name \"some-name\"; } or { $c has name \"the-company\"; }; ");