Skip to content

Cypher: Types are not automatically created when creating a constraint #3760

@Orkie

Description

@Orkie

When I try to create a constraint via Cypher, it seems that the types are not automatically created as they are when you just create a node, and the command fails. I'm not sure if this is intentional.

e.g.

CREATE CONSTRAINT type_id_constraint IF NOT EXISTS FOR (t:Type) REQUIRE t.id IS UNIQUE

yields

Error executing Cypher command: CREATE CONSTRAINT type_id_constraint IF NOT EXISTS FOR (t:Type) REQUIRE t.id IS UNIQUE

But if I run CREATE (t:Type {id:"test"}) first, then it succeeds.

There seems to be no way to create types (or indices?) via Cypher based on the documentation, it looks like you have to drop into SQL to do this - it'd be nice not to need multiple different connections and languages to set up the DB programmatically. Maybe a small extension to opencypher is needed? Or is it possible to specify SQL for a single query run via Bolt?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions