openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r884233 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Date Wed, 25 Nov 2009 19:32:16 GMT
Author: ppoddar
Date: Wed Nov 25 19:32:15 2009
New Revision: 884233

URL: http://svn.apache.org/viewvc?rev=884233&view=rev
Log:
Special comparison for two boolean constants

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=884233&r1=884232&r2=884233&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Nov 25 19:32:15 2009
@@ -2888,6 +2888,16 @@
         boolean castrhs = false;
         Class lc = Filters.wrap(lhs.getType());
         Class rc = Filters.wrap(rhs.getType());
+        
+        // special case of comparison of two boolean constants
+        // because some databases do not like false = false or false = true
+        // but all databases understand 1 = 0 or 0 <> 1 etc.
+        if (lc == rc && lc == Boolean.class && lhs.isConstant() &&
rhs.isConstant()) {
+            String lvalue = Boolean.TRUE.equals(lhs.getValue()) ? "1" : "0";
+            String rvalue = Boolean.TRUE.equals(rhs.getValue()) ? "1" : "0";
+            buf.append(lvalue).append(op).append(rvalue);
+            return;
+        }
         int type = 0;
         if (requiresCastForComparisons && (lc != rc
             || (lhs.isConstant() && rhs.isConstant()))) {



Mime
View raw message