From cde7b3ef8867ca46be2da5e04c63064a1579213f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Pryce-=C3=85klundh?= <112686610+JPryce-Aklundh@users.noreply.github.com> Date: Tue, 7 Jan 2025 10:40:18 +0100 Subject: [PATCH 1/3] add dynamic referencing --- modules/ROOT/pages/syntax/parameters.adoc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/ROOT/pages/syntax/parameters.adoc b/modules/ROOT/pages/syntax/parameters.adoc index 41a006e10..8f49a0772 100644 --- a/modules/ROOT/pages/syntax/parameters.adoc +++ b/modules/ROOT/pages/syntax/parameters.adoc @@ -15,14 +15,15 @@ Additionally, parameters make caching of execution plans much easier for Cypher, Parameters can be used for: -* literals and expressions -* node and relationship ids +* Literals and expressions. +* Node and relationship ids. +* 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]). label:new[Introduced in 5.26] Parameters cannot be used for the following constructs, as these form part of the query structure that is compiled into a query plan: -* property keys; so `MATCH (n) WHERE n.$param = 'something'` is invalid -* relationship types; so `MATCH (n)-[:$param]->(m)` is invalid -* labels; so `MATCH (n:$param)` is invalid +* Property keys; `MATCH (n) WHERE n.$param = 'something'` is invalid. +* Relationship types; `MATCH (n)-[:$param]->(m)` is invalid. +* Node labels; `MATCH (n:$param)` is invalid. Parameters may consist of letters and numbers, and any combination of these, but cannot start with a number or a currency symbol. From 7d0751158e3277681a186a57696c08255db00ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Pryce-=C3=85klundh?= <112686610+JPryce-Aklundh@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:04:10 +0100 Subject: [PATCH 2/3] add properties --- modules/ROOT/pages/clauses/where.adoc | 11 +++++++++-- modules/ROOT/pages/syntax/parameters.adoc | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/ROOT/pages/clauses/where.adoc b/modules/ROOT/pages/clauses/where.adoc index 90334ffab..a021f9c0d 100644 --- a/modules/ROOT/pages/clauses/where.adoc +++ b/modules/ROOT/pages/clauses/where.adoc @@ -185,12 +185,19 @@ The `name`, `age` and `email` values for `Peter` are returned because `Andy` has To filter on a property using a dynamically computed name, use square bracket syntax: +.Parameters +[source, parameters] +---- +{ + "propname": "age" +} +---- + .Query [source, cypher] ---- -WITH 'AGE' AS propname MATCH (n:Person) -WHERE n[toLower(propname)] < 30 +WHERE n[$propname] < 30 RETURN n.name, n.age ---- diff --git a/modules/ROOT/pages/syntax/parameters.adoc b/modules/ROOT/pages/syntax/parameters.adoc index 8f49a0772..f982072eb 100644 --- a/modules/ROOT/pages/syntax/parameters.adoc +++ b/modules/ROOT/pages/syntax/parameters.adoc @@ -17,6 +17,7 @@ Parameters can be used for: * Literals and expressions. * Node and relationship ids. +* Properties, when referenced dynamically (for more information, see xref:clauses/where.adoc#filter-on-dynamic-property[filter-on-dynamic-property]). * 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]). label:new[Introduced in 5.26] Parameters cannot be used for the following constructs, as these form part of the query structure that is compiled into a query plan: From 8013136e7e756288df83a00fefc71319e0c1b796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Pryce-=C3=85klundh?= <112686610+JPryce-Aklundh@users.noreply.github.com> Date: Tue, 7 Jan 2025 11:11:34 +0100 Subject: [PATCH 3/3] fix xref --- modules/ROOT/pages/syntax/parameters.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/syntax/parameters.adoc b/modules/ROOT/pages/syntax/parameters.adoc index f982072eb..06a4f0605 100644 --- a/modules/ROOT/pages/syntax/parameters.adoc +++ b/modules/ROOT/pages/syntax/parameters.adoc @@ -17,7 +17,7 @@ Parameters can be used for: * Literals and expressions. * Node and relationship ids. -* Properties, when referenced dynamically (for more information, see xref:clauses/where.adoc#filter-on-dynamic-property[filter-on-dynamic-property]). +* Properties, when referenced dynamically (for more information, see xref:clauses/where.adoc#filter-on-dynamic-property[Filter on dynamically-computed node property]). * 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]). label:new[Introduced in 5.26] Parameters cannot be used for the following constructs, as these form part of the query structure that is compiled into a query plan: