typeql icon indicating copy to clipboard operation
typeql copied to clipboard

Discrepancies when parsing patterns containing a disjunction in Java

Open jmsfltchr opened this issue 4 years ago • 0 comments

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

  1. OS (where Grakn server runs): Mac OS 10
  2. Grakn version (and platform): Grakn Core 1.8
  3. 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\"; }; ");

jmsfltchr avatar Jun 22 '20 10:06 jmsfltchr