cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1509720 - /cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/Evaluator.java
Date Fri, 02 Aug 2013 14:00:04 GMT
Author: aadamchik
Date: Fri Aug  2 14:00:03 2013
New Revision: 1509720

URL: http://svn.apache.org/r1509720
Log:
CAY-1860  In-memory matching of DataObjects against ObjectId or int

making sure we don't round decimal numbers in comparison

Modified:
    cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/Evaluator.java

Modified: cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/Evaluator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/Evaluator.java?rev=1509720&r1=1509719&r2=1509720&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/Evaluator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-core-unpublished/src/main/java/org/apache/cayenne/exp/parser/Evaluator.java
Fri Aug  2 14:00:03 2013
@@ -111,7 +111,15 @@ abstract class Evaluator {
                 }
 
                 if (rhs instanceof Number) {
-                    return Cayenne.longPKForObject(lhsPersistent) == ((Number) rhs).longValue();
+
+                    // only care about whole numbers
+                    if (rhs instanceof Integer) {
+                        return Cayenne.longPKForObject(lhsPersistent) == ((Number) rhs).longValue();
+                    }
+
+                    if (rhs instanceof Long) {
+                        return Cayenne.longPKForObject(lhsPersistent) == ((Number) rhs).longValue();
+                    }
                 }
 
                 return Cayenne.pkForObject(lhsPersistent).equals(rhs);
@@ -151,11 +159,11 @@ abstract class Evaluator {
     }
 
     static <T> Evaluator evaluator(Object lhs) {
-        
-        if(lhs == null) {
+
+        if (lhs == null) {
             return DEFAULT_EVALUATOR;
         }
-        
+
         Class<?> lhsType = lhs.getClass();
 
         Evaluator e = evaluators.get(lhsType);



Mime
View raw message