cleishm / libcypher-parser

Cypher Parser Library
Apache License 2.0
147 stars 39 forks source link

Incorrect constraint error #42

Open AdrienLemaire opened 3 years ago

AdrienLemaire commented 3 years ago
$ cypher-lint -a < scripts/upload_t10_data.cypher
<stdin>:2:19: Invalid input 'u': expected '=' or CREATE CONSTRAINT ON
CREATE CONSTRAINT uniqueT10 IF NOT EXISTS ON (n:T10)
                  ^
<stdin>:5:19: Invalid input 'u': expected '=' or CREATE CONSTRAINT ON
CREATE CONSTRAINT uniqueMonth IF NOT EXISTS ON (m:Month)
                  ^
  @0     2..33    line_comment                // Make sure we have unique nodes
  @1    34..145   error                       >>CREATE CONSTRAINT uniqueT10 IF NOT EXISTS ON (n:T10)\n      ASSERT (n.date, n.name, n.result, n.m50) IS NODE KEY<<
  @2   149..175   line_comment                // Constraint for Month/Year
  @3   176..275   error                       >>CREATE CONSTRAINT uniqueMonth IF NOT EXISTS ON (m:Month)\n      ASSERT (m.month, m.year) IS NODE KEY<<
  @4   280..327   line_comment                // Needs apoc.import.file.enabled=true  in config

According to the cypher refcard, the following constraints format is acceptable (and working as expected):

// Make sure we have unique nodes
CREATE CONSTRAINT uniqueT10 IF NOT EXISTS ON (n:T10)
      ASSERT (n.date, n.name, n.result, n.m50) IS NODE KEY;
// Constraint for Month/Year
CREATE CONSTRAINT uniqueMonth IF NOT EXISTS ON (m:Month)
      ASSERT (m.month, m.year) IS NODE KEY;