You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cypher: Types are not automatically created when creating a constraint #3760
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?
Activity
lvca commentedon Apr 1, 2026
On it.
fix: create types automatically on Cypher DDL
lvca commentedon Apr 1, 2026
FIxed.
Orkie commentedon Apr 1, 2026
Thanks! Just built locally and tested, seems to be working.
On indices, is there a way to create them with Cypher / through the bolt connector somehow at the moment?
lvca commentedon Apr 1, 2026
What's the cypher command you would use to create indexes? I meant, with neo4j? We could implement that too.
Orkie commentedon Apr 1, 2026
Something like this for example is what we have used in the past:
Memgraph has a different syntax:
lvca commentedon Apr 1, 2026
After a quick research, I can confirm, this is part of OpenCypher v25 we already parse:
I'm going to implement this in a new issue.
lvca commentedon Apr 1, 2026
#3763
lvca commentedon Apr 1, 2026
Already implemented
fix: create types automatically on Cypher DDL
fix: create types automatically on Cypher DDL
chore(deps-dev): bump org.mockito:mockito-core from 5.20.0 to 5.21.0 …
fix: create types automatically on Cypher DDL
fix: create types automatically on Cypher DDL
fix: create types automatically on Cypher DDL