jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r785589 - in /jackrabbit/trunk/jackrabbit-spi-commons/src: main/java/org/apache/jackrabbit/spi/commons/query/sql2/ main/java/org/apache/jackrabbit/spi/commons/value/ test/java/org/apache/jackrabbit/spi/commons/query/sql2/ test/resources/org...
Date Wed, 17 Jun 2009 13:21:37 GMT
Author: thomasm
Date: Wed Jun 17 13:21:36 2009
New Revision: 785589

URL: http://svn.apache.org/viewvc?rev=785589&view=rev
Log:
JCR-2157 SQL2 parser: Support CAST

Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt

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=785589&r1=785588&r2=785589&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
Wed Jun 17 13:21:36 2009
@@ -494,20 +494,15 @@
         if (readIf("STRING")) {
             return valueFactory.createValue(value.getString());
         } else if(readIf("BINARY")) {
-            // TODO getBinary
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getBinary());
         } else if(readIf("DATE")) {
-            // TODO getDate
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getDate());
         } else if(readIf("LONG")) {
-            // TODO getLong
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getLong());
         } else if(readIf("DOUBLE")) {
-            // TODO getDouble
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getDouble());
         } else if(readIf("DECIMAL")) {
-            // TODO getDecimal
-            return valueFactory.createValue(value.getString());
+            return valueFactory.createValue(value.getDecimal());
         } else if(readIf("BOOLEAN")) {
             return valueFactory.createValue(value.getBoolean());
         } else if(readIf("NAME")) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java?rev=785589&r1=785588&r2=785589&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/value/QValueValue.java
Wed Jun 17 13:21:36 2009
@@ -100,6 +100,7 @@
             case PropertyType.DOUBLE:
             case PropertyType.LONG:
             case PropertyType.DATE:
+            case PropertyType.STRING:
                 return qvalue.getDecimal();
             default:
                 throw new ValueFormatException("incompatible type " + PropertyType.nameFromValue(qvalue.getType()));
@@ -177,7 +178,7 @@
     }
 
     /**
-     * @see javax.jcr.Value#getType() 
+     * @see javax.jcr.Value#getType()
      */
     public int getType() {
         return qvalue.getType();
@@ -196,7 +197,7 @@
     }
 
     /**
-     * @see Object#hashCode() 
+     * @see Object#hashCode()
      */
     public int hashCode() {
         return qvalue.hashCode();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java?rev=785589&r1=785588&r2=785589&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java
Wed Jun 17 13:21:36 2009
@@ -23,6 +23,7 @@
 import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFactory;
+import javax.jcr.ValueFormatException;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.qom.QueryObjectModel;
 import junit.framework.TestCase;
@@ -42,7 +43,7 @@
     protected Parser parser;
 
     protected Random random = new Random();
-    
+
     static class QOMF extends QueryObjectModelFactoryImpl  {
 
         public QOMF(NamePathResolver resolver, ValueFactory factory) {
@@ -53,12 +54,12 @@
                 RepositoryException {
             return null;
         }
-        
+
     };
 
     protected void setUp() throws Exception {
         super.setUp();
-        NamePathResolver resolver = new DefaultNamePathResolver(new DummyNamespaceResolver());
       
+        NamePathResolver resolver = new DefaultNamePathResolver(new DummyNamespaceResolver());
         ValueFactory vf = new ValueFactoryQImpl(QValueFactoryImpl.getInstance(), resolver);
         QueryObjectModelFactoryImpl factory = new QOMF(resolver, vf);
         parser = new Parser(factory, vf);
@@ -130,6 +131,8 @@
             String q = buff.toString();
             try {
                 parser.createQueryObjectModel(q);
+            } catch (ValueFormatException e) {
+                // OK
             } catch (InvalidQueryException e) {
                 // OK
             } catch (NamespaceException e) {

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt?rev=785589&r1=785588&r2=785589&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/org/apache/jackrabbit/spi/commons/query/sql2/test.sql2.txt
Wed Jun 17 13:21:36 2009
@@ -159,7 +159,7 @@
 select * from test where active=""
 select * from test where a=cast('0.01' as string)
 select * from test where a=cast('abcdef' as binary)
-select * from test where a=cast('+2001-01-01T01:02:03-00:30' as date)
+select * from test where a=cast('+2001-01-01T01:02:03.000Z' as date)
 select * from test where a=cast('10' as long)
 select * from test where a=cast('100.5' as double)
 select * from test where a=cast('3.11' as decimal)



Mime
View raw message