Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aks043 opened this issue Oct 3, 2023 · 1 comment

Comments

@aks043
Copy link

aks043 commented Oct 3, 2023

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
@nadja-muller
Copy link
Contributor

Thank you for reporting this. We will come back to you once we've fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants