Skip to content

Commit 1418736

Browse files
Add dynamically referenced labels and types to allowed parameters (#1144)
1 parent 7a1fc2a commit 1418736

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

modules/ROOT/pages/clauses/where.adoc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,19 @@ The `name`, `age` and `email` values for `Peter` are returned because `Andy` has
185185

186186
To filter on a property using a dynamically computed name, use square bracket syntax:
187187

188+
.Parameters
189+
[source, parameters]
190+
----
191+
{
192+
"propname": "age"
193+
}
194+
----
195+
188196
.Query
189197
[source, cypher]
190198
----
191-
WITH 'AGE' AS propname
192199
MATCH (n:Person)
193-
WHERE n[toLower(propname)] < 30
200+
WHERE n[$propname] < 30
194201
RETURN n.name, n.age
195202
----
196203

modules/ROOT/pages/syntax/parameters.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ Additionally, parameters make caching of execution plans much easier for Cypher,
1515

1616
Parameters can be used for:
1717

18-
* literals and expressions
19-
* node and relationship ids
18+
* Literals and expressions.
19+
* Node and relationship ids.
20+
* Properties, when referenced dynamically (for more information, see xref:clauses/where.adoc#filter-on-dynamic-property[Filter on dynamically-computed node property]).
21+
* Node labels and relationship types, when referenced dynamically (for more information, see xref:clauses/match.adoc#dynamic-match[`MATCH` using dynamic node labels and relationship types]).
2022

2123
Parameters cannot be used for the following constructs, as these form part of the query structure that is compiled into a query plan:
2224

23-
* property keys; so `MATCH (n) WHERE n.$param = 'something'` is invalid
24-
* relationship types; so `MATCH (n)-[:$param]->(m)` is invalid
25-
* labels; so `MATCH (n:$param)` is invalid
25+
* Property keys; `MATCH (n) WHERE n.$param = 'something'` is invalid.
26+
* Relationship types; `MATCH (n)-[:$param]->(m)` is invalid.
27+
* Node labels; `MATCH (n:$param)` is invalid.
2628

2729
Parameters may consist of letters and numbers, and any combination of these, but cannot start with a number or a currency symbol.
2830

0 commit comments

Comments
 (0)