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/11/07 09:57:56 UTC
[sling-org-apache-sling-query] 08/12: Don't add apostrophes to SQL2
queries
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.query-3.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-query.git
commit 58c87394d2de55ab32112f55978ebda3b1ba5e0b
Author: tomekr <to...@unknown>
AuthorDate: Wed Mar 4 12:57:24 2015 +0000
Don't add apostrophes to SQL2 queries
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/sling-query@1663975 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 35ba180..4797b15 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 754c4a7..aee6c5c 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 2b49b2d..e0d7c6e 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>.