You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:25:52 UTC
[sling-org-apache-sling-query] 24/31: SLING-5654 Use apostrophe to
escape paths in ISDESCENDANTNODE
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-query.git
commit a1f01d34ee8808e71fa9cbc176185fac83e5b675
Author: Tomasz Rekawek <to...@apache.org>
AuthorDate: Fri Apr 8 14:02:04 2016 +0000
SLING-5654 Use apostrophe to escape paths in ISDESCENDANTNODE
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1738246 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/sling/query/resource/jcr/query/JcrQueryBuilder.java | 2 +-
.../apache/sling/query/selector/parser/JcrMultiSelectorTest.java | 2 +-
.../org/apache/sling/query/selector/parser/JcrSelectorTest.java | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/sling/query/resource/jcr/query/JcrQueryBuilder.java b/src/main/java/org/apache/sling/query/resource/jcr/query/JcrQueryBuilder.java
index 4797b15..fd52900 100644
--- a/src/main/java/org/apache/sling/query/resource/jcr/query/JcrQueryBuilder.java
+++ b/src/main/java/org/apache/sling/query/resource/jcr/query/JcrQueryBuilder.java
@@ -55,7 +55,7 @@ public class JcrQueryBuilder {
Formula formula = prepareAlternativeConditions(segments);
if (StringUtils.isNotBlank(rootPath) && !"/".equals(rootPath)) {
List<Term> conditions = new ArrayList<Term>();
- conditions.add(new Atomic(String.format("ISDESCENDANTNODE([%s])", rootPath)));
+ conditions.add(new Atomic(String.format("ISDESCENDANTNODE('%s')", rootPath)));
if (formula != null) {
conditions.add(formula);
}
diff --git a/src/test/java/org/apache/sling/query/selector/parser/JcrMultiSelectorTest.java b/src/test/java/org/apache/sling/query/selector/parser/JcrMultiSelectorTest.java
index aee6c5c..55f59c3 100644
--- a/src/test/java/org/apache/sling/query/selector/parser/JcrMultiSelectorTest.java
+++ b/src/test/java/org/apache/sling/query/selector/parser/JcrMultiSelectorTest.java
@@ -52,7 +52,7 @@ public class JcrMultiSelectorTest {
@Test
public void attributesWithPath() {
final String selector = "[x=y][y=z], [a=b][c=d]";
- final String jcrQuery = "SELECT * FROM [nt:base] AS s WHERE (ISDESCENDANTNODE([/content]) AND ((s.[x] = 'y' AND s.[y] = 'z') OR (s.[a] = 'b' AND s.[c] = 'd')))";
+ final String jcrQuery = "SELECT * FROM [nt:base] AS s WHERE (ISDESCENDANTNODE('/content') AND ((s.[x] = 'y' AND s.[y] = 'z') OR (s.[a] = 'b' AND s.[c] = 'd')))";
Assert.assertEquals(jcrQuery, parse(selector, "/content"));
}
}
diff --git a/src/test/java/org/apache/sling/query/selector/parser/JcrSelectorTest.java b/src/test/java/org/apache/sling/query/selector/parser/JcrSelectorTest.java
index e0d7c6e..ec8c71f 100644
--- a/src/test/java/org/apache/sling/query/selector/parser/JcrSelectorTest.java
+++ b/src/test/java/org/apache/sling/query/selector/parser/JcrSelectorTest.java
@@ -47,7 +47,7 @@ public class JcrSelectorTest {
@Test
public void parsePath() {
final String selector = "cq:Page";
- final String jcrQuery = "SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE([/content])";
+ final String jcrQuery = "SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE('/content')";
Assert.assertEquals(jcrQuery, parse(selector, "/content"));
}
@@ -117,14 +117,14 @@ public class JcrSelectorTest {
@Test
public void parseMultipleConditionsWithResourceTypeAndPath() {
final String selector = "foundation/components/parsys[key1=value1][key2=value2]";
- final String jcrQuery = "SELECT * FROM [nt:base] AS s WHERE (ISDESCENDANTNODE([/content]) AND (s.[sling:resourceType] = 'foundation/components/parsys' AND s.[key1] = 'value1' AND s.[key2] = 'value2'))";
+ final String jcrQuery = "SELECT * FROM [nt:base] AS s WHERE (ISDESCENDANTNODE('/content') AND (s.[sling:resourceType] = 'foundation/components/parsys' AND s.[key1] = 'value1' AND s.[key2] = 'value2'))";
Assert.assertEquals(jcrQuery, parse(selector, "/content"));
}
@Test
public void parseAttributeWithSubresource() {
final String selector = "cq:Page[jcr:content/cq:template=xyz]";
- final String jcrQuery = "SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE([/content])";
+ final String jcrQuery = "SELECT * FROM [cq:Page] AS s WHERE ISDESCENDANTNODE('/content')";
Assert.assertEquals(jcrQuery, parse(selector, "/content"));
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.