jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1338598 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
Date Tue, 15 May 2012 08:46:06 GMT
Author: thomasm
Date: Tue May 15 08:46:06 2012
New Revision: 1338598

URL: http://svn.apache.org/viewvc?rev=1338598&view=rev
Log:
OAK-36 Implement a query parser - support CONTAINS(*, ...)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java?rev=1338598&r1=1338597&r2=1338598&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
Tue May 15 08:46:06 2012
@@ -334,24 +334,36 @@ public class SQL2Parser {
     private ConstraintImpl parseConditionFunctionIf(String functionName) throws ParseException
{
         ConstraintImpl c;
         if ("CONTAINS".equalsIgnoreCase(functionName)) {
-            String name = readName();
-            if (readIf(".")) {
-                if (readIf("*")) {
-                    read(",");
-                    c = factory.fullTextSearch(
-                            name, null, parseStaticOperand());
+            if (readIf("*")) {
+                // strictly speaking, CONTAINS(*, ...) is not supported
+                // according to the spec:
+                // "If only one selector exists in this query, explicit
+                // specification of the selectorName preceding the
+                // propertyName is optional"
+                // but we anyway support it
+                read(",");
+                c = factory.fullTextSearch(
+                        getOnlySelectorName(), null, parseStaticOperand());
+            } else {
+                String name = readName();
+                if (readIf(".")) {
+                    if (readIf("*")) {
+                        read(",");
+                        c = factory.fullTextSearch(
+                                name, null, parseStaticOperand());
+                    } else {
+                        String selector = name;
+                        name = readName();
+                        read(",");
+                        c = factory.fullTextSearch(
+                                selector, name, parseStaticOperand());
+                    }
                 } else {
-                    String selector = name;
-                    name = readName();
                     read(",");
                     c = factory.fullTextSearch(
-                            selector, name, parseStaticOperand());
+                            getOnlySelectorName(), name,
+                            parseStaticOperand());
                 }
-            } else {
-                read(",");
-                c = factory.fullTextSearch(
-                        getOnlySelectorName(), name,
-                        parseStaticOperand());
             }
         } else if ("ISSAMENODE".equalsIgnoreCase(functionName)) {
             String name = readName();



Mime
View raw message