jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1370294 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
Date Tue, 07 Aug 2012 14:58:32 GMT
Author: thomasm
Date: Tue Aug  7 14:58:32 2012
New Revision: 1370294

URL: http://svn.apache.org/viewvc?rev=1370294&view=rev
Log:
OAK-225 Sling I18N queries not supported by Oak (partial fix)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java?rev=1370294&r1=1370293&r2=1370294&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
Tue Aug  7 14:58:32 2012
@@ -381,10 +381,20 @@ public class XPathToSQL2Converter {
             Cast c = new Cast(expr, "date");
             read(")");
             return c;
+        } else if ("fn:lower-case".equals(functionName)) {
+            Function f = new Function("lower");
+            f.params.add(parseExpression());
+            read(")");
+            return f;
+        } else if ("fn:upper-case".equals(functionName)) {
+            Function f = new Function("upper");
+            f.params.add(parseExpression());
+            read(")");
+            return f;
         // } else if ("jcr:deref".equals(functionName)) {
             // TODO support jcr:deref?
         } else {
-            throw getSyntaxError("jcr:like | jcr:contains | jcr:score | jcr:deref");
+            throw getSyntaxError("jcr:like | jcr:contains | jcr:score | jcr:deref | fn:lower-case
| fn:upper-case");
         }
     }
 
@@ -537,7 +547,9 @@ public class XPathToSQL2Converter {
         case CHAR_NAME:
             while (true) {
                 type = types[i];
-                if (type != CHAR_NAME && type != CHAR_VALUE) {
+                // the '-' can be part of a name, 
+                // for example in "fn:lower-case"
+                if (type != CHAR_NAME && type != CHAR_VALUE && chars[i] !=
'-') {
                     c = chars[i];
                     break;
                 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt?rev=1370294&r1=1370293&r2=1370294&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/queryXpathTest.txt
Tue Aug  7 14:58:32 2012
@@ -18,6 +18,14 @@
 # * lines starting with "xpath" are xpath queries, followed by expected sql2 query
 # * use ascii character only
 
+# sling queries
+
+xpath //element(*,mix:language)[fn:lower-case(@jcr:language)='en']//element(*,sling:Message)[@sling:message]/(@sling:key|@sling:message)
+select [jcr:path], [jcr:score], [sling:key], [sling:message] from [sling:Message] where (lower([jcr:language])
= 'en') and ([sling:message] is not null)
+
+xpath //element(*,mix:language)[fn:upper-case(@jcr:language)='en']//element(*,sling:Message)[@sling:message]/(@sling:key|@sling:message)
+select [jcr:path], [jcr:score], [sling:key], [sling:message] from [sling:Message] where (upper([jcr:language])
= 'en') and ([sling:message] is not null)
+
 # jboss example queries
 
 xpath //*
@@ -229,7 +237,7 @@ xpath //element(*, my:type)[@my:value = 
 invalid: Query: //element(*, my:type)[@my:value = [(*)'x']; expected: @, true, false, -,
+
 
 xpath //element(*, my:type)[jcr:strike(@title,'%Java%')]
-invalid: Query: //element(*, my:type)[jcr:strike(@(*)title,'%Java%')]; expected: jcr:like
| jcr:contains | jcr:score | jcr:deref
+invalid: Query: //element(*, my:type)[jcr:strike(@(*)title,'%Java%')]; expected: jcr:like
| jcr:contains | jcr:score | jcr:deref | fn:lower-case | fn:upper-case
 
 xpath //element(*, my:type)[
 invalid: Query: //element(*, my:type)(*)[; expected: not, (, @, true, false, -, +



Mime
View raw message