cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1563598 - in /cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne: access/ReturnTypesMappingTest.java unit/MySQLUnitDbAdapter.java unit/UnitDbAdapter.java
Date Sun, 02 Feb 2014 12:50:27 GMT
Author: aadamchik
Date: Sun Feb  2 12:50:26 2014
New Revision: 1563598

URL: http://svn.apache.org/r1563598
Log:
fixing REAL unit test on MySQL

Modified:
    cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java
    cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLUnitDbAdapter.java
    cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java?rev=1563598&r1=1563597&r2=1563598&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/ReturnTypesMappingTest.java
Sun Feb  2 12:50:26 2014
@@ -600,8 +600,16 @@ public class ReturnTypesMappingTest exte
         DataRow testRead = (DataRow) context.performQuery(q).get(0);
         Object columnValue = testRead.get(columnName);
         assertNotNull(columnValue);
-        assertEquals(Float.class, columnValue.getClass());
-        assertEquals(realValue, columnValue);
+
+        // MySQL can treat REAL as either DOUBLE or FLOAT depending on the
+        // engine settings
+        if (unitDbAdapter.realAsDouble()) {
+            assertEquals(Double.class, columnValue.getClass());
+            assertEquals(Double.valueOf(realValue), (Double) columnValue, 0.0001);
+        } else {
+            assertEquals(Float.class, columnValue.getClass());
+            assertEquals(realValue, columnValue);
+        }
     }
 
     public void testREAL2() throws Exception {

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLUnitDbAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLUnitDbAdapter.java?rev=1563598&r1=1563597&r2=1563598&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLUnitDbAdapter.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLUnitDbAdapter.java
Sun Feb  2 12:50:26 2014
@@ -40,6 +40,13 @@ public class MySQLUnitDbAdapter extends 
     public MySQLUnitDbAdapter(DbAdapter adapter) {
         super(adapter);
     }
+    
+    @Override
+    public boolean realAsDouble() {
+        // this actually depends on the "sql_mode" var in MYSQL. However the
+        // default is REAL == DOUBLE
+        return true;
+    }
 
     @Override
     public boolean supportsLobs() {

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java?rev=1563598&r1=1563597&r2=1563598&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
Sun Feb  2 12:50:26 2014
@@ -66,6 +66,16 @@ public class UnitDbAdapter {
         }
         this.adapter = adapter;
     }
+    
+    /**
+     * Returns whether the target DB treats REAL values as DOUBLEs. Default is
+     * false, i.e. REALs are treated as FLOATs.
+     * 
+     * @return
+     */
+    public boolean realAsDouble() {
+        return false;
+    }
 
     /**
      * Drops all table constraints.



Mime
View raw message