apoc icon indicating copy to clipboard operation
apoc copied to clipboard

apoc.export.cypher.schema() is only returning unique constraints and index cypher queries its not returning ` IS NOT NULL` constraints

Open aks043 opened this issue 1 year ago • 1 comments

Guidelines

Please note that GitHub issues are only meant for bug reports/feature requests. If you have questions on how to use APOC, please ask on the Neo4j Discussion Forum instead of creating an issue here.

Expected Behavior (Mandatory)

once we call apoc.export.cypher.schema() it should return all cypher statements for all constraints and index . Let us assume current stte of schema for our db is -

  1. We have one unique constraint unique_person on label Person on property id
  2. One index idx_person_surname on label Person on property surname
  3. One constraint person_has_name IS NOT NULL on label Person for property surname Once i run apoc.export.cypher.schema() it should return me all three cypher statements of current schema.

Actual Behavior (Mandatory)

For our above example its returning cypher statements for unique constraints and index but its not returning for IS NOT NULL type cypher queries.

How to Reproduce the Problem

Steps -

  1. Execute these cypher queries CREATE CONSTRAINT unique_person IF NOT EXISTS FOR (p:Person) REQUIRE p.id IS UNIQUE; CREATE CONSTRAINT person_has_name IF NOT EXISTS FOR (p:Person) REQUIRE p.name IS NOT NULL; CREATE INDEX idx_person_surname IF NOT EXISTS FOR (p:Person) ON (p.surname);
  2. Now check for constraints by show constraints and we will find two constraints 'person_has_name' and 'unique_person' and once we would check indexes by cypher statements - show indexes we would found that it returns idx_person_surname and unique_person which is as expected .
  3. Now execute apoc function CALL apoc.export.cypher.schema() . In response we would get only CREATE RANGE INDEX FOR (n:Person) ON (n.surname); CREATE CONSTRAINT unique_person FOR (node:Person) REQUIRE (node.id) IS UNIQUE; Here it dos not give response for IS NOT NULL constraints

Simple Dataset (where it's possibile)

Just setup a empty database and execute process described in How to reproduce the Problem

//Insert here a set of Cypher statements that helps us to reproduce the problem
CREATE CONSTRAINT unique_person IF NOT EXISTS FOR (p:Person) REQUIRE p.id IS UNIQUE;
CREATE CONSTRAINT person_has_name IF NOT EXISTS FOR (p:Person) REQUIRE p.name IS NOT NULL;
CREATE INDEX idx_person_surname IF NOT EXISTS FOR (p:Person) ON (p.surname);

// check in neo4j 
show constraints;
show indexes;

// call apoc function
CALL apoc.export.cypher.schema() 



Steps (Mandatory)

1.set up neo4j with apoc-core library 2.CREATE CONSTRAINT unique_person IF NOT EXISTS FOR (p:Person) REQUIRE p.id IS UNIQUE; CREATE CONSTRAINT person_has_name IF NOT EXISTS FOR (p:Person) REQUIRE p.name IS NOT NULL; CREATE INDEX idx_person_surname IF NOT EXISTS FOR (p:Person) ON (p.surname); 3.check response of CALL apoc.export.cypher.schema() ; there would be no constraints person_has_name

Screenshots (where it's possibile)

Screenshot from 2023-10-03 12-34-55

Specifications (Mandatory)

Currently used versions we have tried this on neo4j enterprise version 5.6.0 with apoc-core 5.6.0 also tried on 5.7.0 of both and 5.8.0 of both .

Versions

  • OS: Ubuntu 22.04.3 LTS
  • Neo4j:Enterprise 5.6.0 , 5.7.0, 5.8.0
  • Neo4j-Apoc:apoc-core 5.6.0, 5.7.0, 5.8.0

aks043 avatar Oct 03 '23 07:10 aks043