Skip to content

Commit 1298a9f

Browse files
mnd999Hunternessrenetapopova
authored
Errors for Graph Type (#341)
Error codes for graph types. This work is likely to be feature flagged for some time, so we don't want to merge it to the public docs yet, but we do need to review the errors. --------- Co-authored-by: Therese Magnusson <[email protected]> Co-authored-by: Reneta Popova <[email protected]>
1 parent 7b081c7 commit 1298a9f

File tree

18 files changed

+937
-1
lines changed

18 files changed

+937
-1
lines changed

modules/ROOT/content-nav.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,21 @@
160160
**** xref:errors/gql-errors/22NBD.adoc[]
161161
**** xref:errors/gql-errors/22NBE.adoc[]
162162
**** xref:errors/gql-errors/22NBF.adoc[]
163+
**** xref:errors/gql-errors/22NC1.adoc[]
164+
**** xref:errors/gql-errors/22NC2.adoc[]
165+
**** xref:errors/gql-errors/22NC3.adoc[]
166+
**** xref:errors/gql-errors/22NC4.adoc[]
167+
**** xref:errors/gql-errors/22NC5.adoc[]
168+
**** xref:errors/gql-errors/22NC6.adoc[]
169+
**** xref:errors/gql-errors/22NC7.adoc[]
170+
**** xref:errors/gql-errors/22NC8.adoc[]
171+
**** xref:errors/gql-errors/22NC9.adoc[]
172+
**** xref:errors/gql-errors/22NCA.adoc[]
173+
**** xref:errors/gql-errors/22NCB.adoc[]
174+
**** xref:errors/gql-errors/22NCC.adoc[]
175+
**** xref:errors/gql-errors/22NCD.adoc[]
176+
**** xref:errors/gql-errors/22NCE.adoc[]
177+
**** xref:errors/gql-errors/22NCF.adoc[]
163178
*** xref:errors/gql-errors/index.adoc#invalid-transaction-state[Invalid transaction state]
164179
**** xref:errors/gql-errors/25G02.adoc[]
165180
**** xref:errors/gql-errors/25N01.adoc[]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
= 22NC1
2+
3+
== Status description
4+
error: data exception - graph type element contains duplicated tokens. The graph type element includes a property key with name `{ <<propKey>> }` more than once.
5+
6+
== Explanation
7+
When defining a graph type, node and relationship element types may only define a property once.
8+
9+
== Example scenario
10+
For example, try to set a graph type as follows:
11+
12+
[source,cypher]
13+
----
14+
ALTER CURRENT GRAPH TYPE SET {
15+
(n:Node => {prop::STRING, prop::INTEGER})
16+
}
17+
----
18+
19+
The query returns an error with GQLSTATUS 22NC1 and the status description:
20+
21+
[source]
22+
----
23+
error: data exception - graph type element contains duplicated tokens. The graph type element includes a property key with name `prop` more than once.
24+
----
25+
26+
To fix this, remove the duplicate property key definition or uniquely name the property keys:
27+
28+
[source, cypher]
29+
----
30+
ALTER CURRENT GRAPH TYPE SET {
31+
(p:Node => {prop :: STRING, prop2 :: INTEGER})
32+
}
33+
----
34+
35+
ifndef::backend-pdf[]
36+
[discrete.glossary]
37+
== Glossary
38+
39+
include::partial$glossary.adoc[]
40+
endif::[]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
= 22NC2
2+
3+
== Status description
4+
error: data exception - node element type has no effect. The node element type `{ <<label>> }` must contain one or more implied labels, or at least one property type.
5+
6+
== Explanation
7+
When defining a graph type, node element types must have some effect; otherwise, they are not allowed.
8+
9+
== Example scenario
10+
For example, try to set a graph type as follows:
11+
12+
[source,cypher]
13+
----
14+
ALTER CURRENT GRAPH TYPE SET {
15+
(n:Node => )
16+
}
17+
----
18+
19+
The query returns an error with GQLSTATUS 22NC2 and the status description:
20+
21+
[source]
22+
----
23+
error: data exception - node element type is has no effect. The node element type `Node` must contain one or more implied labels, or at least one property type.
24+
----
25+
26+
To fix this, define at least one property type or add an implied label, for example:
27+
28+
[source,cypher]
29+
----
30+
ALTER CURRENT GRAPH TYPE SET {
31+
(n:Node => { prop :: ANY NOT NULL })
32+
}
33+
----
34+
35+
ifndef::backend-pdf[]
36+
[discrete.glossary]
37+
== Glossary
38+
39+
include::partial$glossary.adoc[]
40+
endif::[]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
= 22NC3
2+
3+
== Status description
4+
error: data exception - relationship element type has no effect. The relationship element type `{ <<relType>> }` must define a source, destination, or at least one property type.
5+
6+
== Explanation
7+
When defining a graph type, relationship element types must have some effect.
8+
To be effective, a relationship element type must define at least one of the following:
9+
10+
* a source node element type or label
11+
* a destination node element type or label
12+
* at least one property type
13+
14+
== Example scenario
15+
For example, try to set a graph type as follows:
16+
17+
[source,cypher]
18+
----
19+
ALTER CURRENT GRAPH TYPE SET {
20+
()-[:REL =>]->()
21+
}
22+
----
23+
24+
The query returns an error with GQLSTATUS 22NC3 and the status description:
25+
26+
[source]
27+
----
28+
error: data exception - relationship element type has no effect. The relationship element type `REL` must define a source or destination, or at least one property type.
29+
----
30+
31+
To fix this, define at least one property type or add a node element type, for example:
32+
33+
[source,cypher]
34+
----
35+
ALTER CURRENT GRAPH TYPE SET {
36+
()-[:REL => {prop: ANY NOT NULL }]->()
37+
}
38+
----
39+
40+
ifndef::backend-pdf[]
41+
[discrete.glossary]
42+
== Glossary
43+
44+
include::partial$glossary.adoc[]
45+
endif::[]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
= 22NC4
2+
3+
== Status description
4+
error: data exception - a label cannot be both identifying and implied. The label(s) `{ <<labelList>> }` are defined as both identifying and implied.
5+
6+
== Explanation
7+
When defining a graph type, labels and relationships must be assigned clear roles.
8+
A label cannot be both "identifying" (to uniquely identify nodes) and "implied" (automatically assigned based on other schema rules) at the same time.
9+
Attempting to define a label as both will result in this error, as it creates ambiguity in the schema definition and node identification process.
10+
11+
== Example scenario
12+
For example, try to set a graph type which defines the node element types `Person` and `Student` with the label `Person` also declared as an implied label on the `Student` node element type as follows:
13+
14+
[source,cypher]
15+
----
16+
ALTER CURRENT GRAPH TYPE SET {
17+
(p:Person => {name :: STRING}),
18+
(s:Student => :Person )
19+
}
20+
----
21+
22+
The query returns an error with GQLSTATUS 22NC4 and the status description:
23+
24+
[source]
25+
----
26+
error: data exception - a label cannot be both identifying and implied. The label(s) `Person` are defined as both identifying and implied.
27+
----
28+
29+
One way to fix this is to add another label to both nodes and capture the property type on `name` there:
30+
31+
[source,cypher]
32+
----
33+
ALTER CURRENT GRAPH TYPE SET {
34+
(p:Person => :Named),
35+
(s:Student => :Named),
36+
CONSTRAINT FOR (:Named) REQUIRE name IS :: STRING
37+
}
38+
----
39+
40+
ifndef::backend-pdf[]
41+
[discrete.glossary]
42+
== Glossary
43+
44+
include::partial$glossary.adoc[]
45+
endif::[]
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
= 22NC5
2+
3+
== Status description
4+
error: data exception - graph type element not found. The `{ <<entityType>> }` element type referenced by `{ <<graphTypeReference>> }` does not exist.
5+
6+
== Explanation
7+
This error occurs when a graph type definition references an element type (such as a node or relationship) using an alias that has not been defined, or by an identifying reference where there is no graph type element identified by that reference.
8+
If the referenced node or relationship type does not exist, the operation cannot proceed and will return an error to indicate the missing element.
9+
10+
== Example scenarios
11+
12+
=== Node element reference does not exist
13+
For example, try to set a graph type with an identifying node element reference that does not exist as follows:
14+
15+
[source,cypher]
16+
----
17+
ALTER CURRENT GRAPH TYPE SET {
18+
(:Node =>)-[e:REL => { prop :: STRING }]->()
19+
}
20+
----
21+
22+
The query returns an error with GQLSTATUS 22NC5 and the status description:
23+
24+
[source]
25+
----
26+
error: data exception - graph type element not found. The node type element referenced by '(:Node =>)' does not exist.
27+
----
28+
In this case, you can make the reference non-identifying, or you can define the node type element before this operation:
29+
30+
[source,cypher]
31+
----
32+
ALTER CURRENT GRAPH TYPE SET {
33+
(:Node)-[e:REL => { prop :: STRING }]->()
34+
}
35+
----
36+
37+
=== Relationship element reference does not exist
38+
For example, try to set a graph type with a relationship element reference that does not exist as follows:
39+
40+
[source,cypher]
41+
----
42+
ALTER CURRENT GRAPH TYPE SET {
43+
CONSTRAINT FOR ()-[b]->() REQUIRE (b.prop) IS KEY
44+
}
45+
46+
----
47+
48+
The query returns an error with GQLSTATUS 22NC5 and the status description:
49+
50+
[source]
51+
----
52+
error: data exception - graph type element not found. The relationship type element referenced by 'b' does not exist.
53+
----
54+
In this case, the reference could be fixed by providing a relationship type:
55+
56+
[source,cypher]
57+
----
58+
ALTER CURRENT GRAPH TYPE SET {
59+
CONSTRAINT FOR ()-[b:REL]->() REQUIRE (b.prop) IS KEY
60+
}
61+
----
62+
63+
=== Element reference omitted from constraint definition
64+
For example, try to define a constraint with an empty node element type reference, which is not allowed as follows:
65+
66+
[source,cypher]
67+
----
68+
ALTER CURRENT GRAPH TYPE SET {
69+
CONSTRAINT FOR () REQUIRE n.prop IS UNIQUE
70+
}
71+
----
72+
73+
The query returns an error with GQLSTATUS 22NC5 and the status description:
74+
75+
[source]
76+
----
77+
error: data exception - graph type element not found. The node type element referenced by 'n' was does not exist.
78+
----
79+
In this case, the reference can be fixed by providing a label for the constraint:
80+
81+
[source,cypher]
82+
----
83+
ALTER CURRENT GRAPH TYPE SET {
84+
CONSTRAINT FOR (n:Node) REQUIRE n.prop IS UNIQUE
85+
}
86+
----
87+
88+
89+
ifndef::backend-pdf[]
90+
[discrete.glossary]
91+
== Glossary
92+
93+
include::partial$glossary.adoc[]
94+
endif::[]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
= 22NC6
2+
3+
== Status description
4+
error: data exception - independent constraint and node element type have the same label.
5+
The independent constraint `{ <<constrDescrOrName>> }` is using the same label `{ <<label>> }` as a node element type.
6+
7+
== Explanation
8+
This error occurs when a label is used both as an identifying label (defining a node element type) and as part of an independent constraint.
9+
A label cannot simultaneously serve as an identifying label and be referenced in an independent constraint.
10+
11+
== Example scenario
12+
For example, try to set a property existence constraint on a property for the label `:Person`, where `:Person` is also defined as an identifying label in the graph type as follows:
13+
14+
[source,cypher]
15+
----
16+
ALTER CURRENT GRAPH TYPE SET {
17+
(p:Person => {name :: STRING}),
18+
CONSTRAINT FOR (p:Person =>) REQUIRE p.name IS NOT NULL
19+
}
20+
----
21+
22+
The query returns an error with GQLSTATUS 22NC6 and the status description:
23+
24+
[source]
25+
----
26+
error: data exception - independent constraint and node element type have the same label. The independent constraint 'Constraint( type='NODE_PROPERTY_EXISTENCE', schema=(:`Person` {`name`}) )' is using the same label `Person` as a node element type.
27+
----
28+
29+
To fix this, define the property existence constraint as part of the node element type:
30+
31+
[source, cypher]
32+
----
33+
ALTER CURRENT GRAPH TYPE SET {
34+
(p:Person => {name :: STRING NOT NULL})
35+
}
36+
----
37+
38+
ifndef::backend-pdf[]
39+
[discrete.glossary]
40+
== Glossary
41+
42+
include::partial$glossary.adoc[]
43+
endif::[]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
= 22NC7
2+
3+
== Status description
4+
error: data exception - independent constraint and relationship element type have the same relationship type.
5+
The independent constraint `{ <<constrDescrOrName>> }` is using the same relationship type `{ <<relType>> }` as a relationship element type.
6+
7+
== Explanation
8+
This error occurs when a relationship type is used both as an identifying relationship type (defining a relationship element type) and as part of an independent constraint.
9+
A relationship type cannot simultaneously serve as an identifying relationship type and be referenced in an independent constraint.
10+
11+
== Example scenario
12+
For example, try to set a property type constraint on a property for the relationship type `:REL`, where `:REL` is also defined as an identifying relationship type in the graph type as follows:
13+
14+
[source,cypher]
15+
----
16+
ALTER CURRENT GRAPH TYPE SET {
17+
()-[:REL => {name :: ANY NOT NULL}]->(),
18+
CONSTRAINT FOR ()-[r:REL =>]->() REQUIRE r.name IS :: STRING
19+
}
20+
----
21+
22+
The query returns an error with GQLSTATUS 22NC7 and the status description:
23+
24+
[source]
25+
----
26+
error: data exception - independent constraint and relationship element type have the same relationship type. The independent constraint 'Constraint( type='RELATIONSHIP_PROPERTY_TYPE', schema=()-[:`REL` {`name`}]-(), propertyType=STRING )' is using the same relationship type `REL` as a relationship element type.
27+
----
28+
29+
To fix this, define the property type constraint as part of the relationship element type:
30+
31+
[source, cypher]
32+
----
33+
ALTER CURRENT GRAPH TYPE SET {
34+
()-[:REL => {name :: STRING NOT NULL}]->()
35+
}
36+
----
37+
38+
ifndef::backend-pdf[]
39+
[discrete.glossary]
40+
== Glossary
41+
42+
include::partial$glossary.adoc[]
43+
endif::[]

0 commit comments

Comments
 (0)