Special comparison for two boolean constants

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@884233 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2009-11-25 19:32:15 +00:00
parent d4010d13e1
commit 3d07bcd372
1 changed files with 10 additions and 0 deletions

View File

@ -2888,6 +2888,16 @@ public class DBDictionary
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()))) {