jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r808431 - /jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
Date Thu, 27 Aug 2009 14:33:40 GMT
Author: thomasm
Date: Thu Aug 27 14:33:40 2009
New Revision: 808431

URL: http://svn.apache.org/viewvc?rev=808431&view=rev
Log:
JCR-2282 SQL2 parser must not infer type for UncastLiteral from static analysis

Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java?rev=808431&r1=808430&r2=808431&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
Thu Aug 27 14:33:40 2009
@@ -455,7 +455,7 @@
             }
         }
         if (currentTokenType == VALUE) {
-            Literal literal = factory.literal(currentValue);
+            Literal literal = getUncastLiteral(currentValue);
             read();
             return literal;
         } else if (currentTokenType == PARAMETER) {
@@ -471,10 +471,10 @@
             }
             return var;
         } else if (readIf("TRUE")) {
-            Literal literal = factory.literal(valueFactory.createValue(true));
+            Literal literal = getUncastLiteral(valueFactory.createValue(true));
             return literal;
         } else if (readIf("FALSE")) {
-            Literal literal = factory.literal(valueFactory.createValue(false));
+            Literal literal = getUncastLiteral(valueFactory.createValue(false));
             return literal;
         } else if (readIf("CAST")) {
             read("(");
@@ -487,6 +487,7 @@
             read("AS");
             value = parseCastAs(value);
             read(")");
+            // CastLiteral
             literal = factory.literal(value);
             return literal;
         } else {
@@ -494,6 +495,19 @@
         }
     }
 
+    /**
+     * Create uncast literal from a value. According to the JCR specification,
+     * "an UncastLiteral is always interpreted as a Value of property type STRING"
+     * (JCR 2.0 Core Specification, 6.7.34 Literal, page 124).
+     * That means the value is converted to a String first.
+     *
+     * @param value the original value
+     * @return the literal
+     */
+    private Literal getUncastLiteral(Value value) throws RepositoryException {
+        return factory.literal(valueFactory.createValue(value.getString()));
+    }
+
     private Value parseCastAs(Value value) throws RepositoryException {
         if (readIf("STRING")) {
             return valueFactory.createValue(value.getString());



Mime
View raw message