adam-cowley / neode

Neo4j OGM for Node.js
MIT License
391 stars 71 forks source link

Incorrect Constraints Query Generated #183

Open ColtraneNadler opened 2 months ago

ColtraneNadler commented 2 months ago

Incorrect Constraints Query Generated

Versions

Problem

Incorrect constraints query being generated by

instance.model('MyNode', {
    customKey: {
        type: 'string',
        unique: true
    },
    mappings: 'string'
 });

instance.schema.install()

Runs the following cypher query

CREATE CONSTRAINT ON (model:MyNode) ASSERT model.customKey IS UNIQUE

which returns the following error ->

  error: Neo4jError: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))
  "CREATE CONSTRAINT ON (model:MyNode) ASSERT model.customKey IS UNIQUE"
   ^
ColtraneNadler commented 2 months ago

Bumping this

ColtraneNadler commented 2 months ago

I created a PR for this issue here https://github.com/adam-cowley/neode/pull/184