empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1379408 - /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java
Date Fri, 31 Aug 2012 10:33:24 GMT
Author: doebele
Date: Fri Aug 31 10:33:23 2012
New Revision: 1379408

URL: http://svn.apache.org/viewvc?rev=1379408&view=rev
Log:
EMPIREDB-157 
improve dataType detection of DBCalcExpr for date operations

Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java?rev=1379408&r1=1379407&r2=1379408&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java
Fri Aug 31 10:33:23 2012
@@ -82,9 +82,16 @@ public class DBCalcExpr extends DBColumn
     {
         DataType type = expr.getDataType();
         // Special treatment for adding days to dates
-        if (type.isDate() && ((value instanceof Date) || value instanceof DBDatabase.DBSystemDate))
-            return DataType.DECIMAL;
-        if ((value instanceof DBColumnExpr))
+        if (type.isDate())
+        {   // see whether the value is a date too
+            if ((value instanceof Date) || 
+                (value instanceof DBDatabase.DBSystemDate) ||
+               ((value instanceof DBColumnExpr) && ((DBColumnExpr)value).getDataType().isDate()))
+            {   // Yes, result is a decimal
+                return DataType.DECIMAL;
+            }
+        }
+        else if ((value instanceof DBColumnExpr))
         {   // Use the value type?
             DataType type2 =  ((DBColumnExpr)value).getDataType();
             if (type2.isNumeric() && type2.ordinal()>type.ordinal())



Mime
View raw message