jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1352121 - /jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java
Date Wed, 20 Jun 2012 14:15:44 GMT
Author: alexparvulescu
Date: Wed Jun 20 14:15:43 2012
New Revision: 1352121

URL: http://svn.apache.org/viewvc?rev=1352121&view=rev
Log:
JCR-3347 Searches on properties of type Decimal give unexpected results

Modified:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java?rev=1352121&r1=1352120&r2=1352121&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SimpleQueryTest.java
Wed Jun 20 14:15:43 2012
@@ -20,6 +20,8 @@ import javax.jcr.Node;
 import javax.jcr.Value;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
+
+import java.math.BigDecimal;
 import java.util.Calendar;
 
 /**
@@ -138,6 +140,38 @@ public class SimpleQueryTest extends Abs
         checkResult(result, 3);
     }
 
+    public void testBigDecimalField() throws Exception {
+        Node n1 = testRootNode.addNode("node1");
+        n1.setProperty(
+                "value",
+                superuser.getValueFactory().createValue(
+                        new BigDecimal(1.9928375d)));
+        Node n2 = testRootNode.addNode("node2");
+        n2.setProperty("value",
+                superuser.getValueFactory().createValue(new BigDecimal(0.0d)));
+        Node n3 = testRootNode.addNode("node3");
+        n3.setProperty(
+                "value",
+                superuser.getValueFactory().createValue(
+                        new BigDecimal(-1.42982475d)));
+        testRootNode.getSession().save();
+
+        String baseSql2 = "SELECT * FROM [nt:base] WHERE ISCHILDNODE(["
+                + testRoot + "]) AND value";
+        checkResult(qm.createQuery(baseSql2 + " > 0.1", Query.JCR_SQL2)
+                .execute(), new Node[] { n1 });
+        checkResult(
+                qm.createQuery(baseSql2 + " = CAST('0' AS DECIMAL)",
+                        Query.JCR_SQL2).execute(), new Node[] { n2 });
+        checkResult(
+                qm.createQuery(baseSql2 + " = CAST(0 AS DECIMAL)",
+                        Query.JCR_SQL2).execute(), new Node[] { n2 });
+        checkResult(qm.createQuery(baseSql2 + " > -0.1", Query.JCR_SQL2)
+                .execute(), new Node[] { n1, n2 });
+        checkResult(qm.createQuery(baseSql2 + " > -1.5", Query.JCR_SQL2)
+                .execute(), new Node[] { n1, n2, n3 });
+    }
+
     public void testLongField() throws Exception {
         Node n = testRootNode.addNode("node1");
         n.setProperty("value", new Value[]{superuser.getValueFactory().createValue(1)});



Mime
View raw message