cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r705982 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test: java/org/apache/cayenne/unit/MySQLStackAdapter.java java/org/apache/cayenne/unit/jira/CAY_1125Test.java resources/ddl/mysql/create-smallint-unsigned.sql
Date Sun, 19 Oct 2008 11:44:50 GMT
Author: aadamchik
Date: Sun Oct 19 04:44:50 2008
New Revision: 705982

URL: http://svn.apache.org/viewvc?rev=705982&view=rev
Log:
CAY-1125 MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer
(can't reproduce)

Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/ddl/mysql/create-smallint-unsigned.sql
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLStackAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLStackAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLStackAdapter.java?rev=705982&r1=705981&r2=705982&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLStackAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/MySQLStackAdapter.java
Sun Oct 19 04:44:50 2008
@@ -64,13 +64,12 @@
 
     @Override
     public void createdTables(Connection con, DataMap map) throws Exception {
+
         if (map.getProcedureMap().containsKey("cayenne_tst_select_proc")) {
             executeDDL(con, "mysql", "create-select-sp.sql");
             executeDDL(con, "mysql", "create-update-sp.sql");
             executeDDL(con, "mysql", "create-update-sp2.sql");
             executeDDL(con, "mysql", "create-out-sp.sql");
-            
-            executeDDL(con, "mysql", "create-smallint-unsigned.sql");
         }
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java?rev=705982&r1=705981&r2=705982&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java
Sun Oct 19 04:44:50 2008
@@ -33,50 +33,71 @@
 
 public class CAY_1125Test extends CayenneCase {
 
+    private boolean isMySQL() {
+        return getAccessStackAdapter() instanceof MySQLStackAdapter;
+    }
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
 
-        deleteTestData();
-        DbEntity artistDB = getDbEntity("ARTIST");
-        artistDB.addAttribute(new DbAttribute(
-                "SMALLINT_UNSIGNED",
-                Types.SMALLINT,
-                artistDB));
-
-        ObjEntity artistObj = getObjEntity("Artist");
-        artistObj.addAttribute(new ObjAttribute(
-                "smallintUnsigned",
-                "java.lang.Integer",
-                artistObj));
-        getDomain().getEntityResolver().clearCache();
+        if (isMySQL()) {
+            deleteTestData();
+
+            createDataContext()
+                    .performGenericQuery(
+                            new SQLTemplate(
+                                    Artist.class,
+                                    "alter table ARTIST ADD COLUMN SMALLINT_UNSIGNED SMALLINT
UNSIGNED NULL"));
+
+            DbEntity artistDB = getDbEntity("ARTIST");
+            artistDB.addAttribute(new DbAttribute(
+                    "SMALLINT_UNSIGNED",
+                    Types.SMALLINT,
+                    artistDB));
+
+            ObjEntity artistObj = getObjEntity("Artist");
+            ObjAttribute artistObjAttr = new ObjAttribute(
+                    "smallintUnsigned",
+                    "java.lang.Integer",
+                    artistObj);
+            artistObjAttr.setDbAttributePath("SMALLINT_UNSIGNED");
+            artistObj.addAttribute(artistObjAttr);
+            getDomain().getEntityResolver().clearCache();
+            getDomain().getEntityResolver().getClassDescriptorMap().clearDescriptors();
+        }
     }
 
     @Override
     protected void tearDown() throws Exception {
         super.tearDown();
 
-        getObjEntity("Artist").removeAttribute("smallintUnsigned");
-        getDbEntity("ARTIST").removeAttribute("SMALLINT_UNSIGNED");
+        if (isMySQL()) {
+
+            getObjEntity("Artist").removeAttribute("smallintUnsigned");
+            getDbEntity("ARTIST").removeAttribute("SMALLINT_UNSIGNED");
+
+            getDomain().getEntityResolver().clearCache();
+            getDomain().getEntityResolver().getClassDescriptorMap().clearDescriptors();
+        }
     }
 
     public void testSQLTemplate() {
-        if (getAccessStackAdapter() instanceof MySQLStackAdapter) {
+        if (isMySQL()) {
 
             SQLTemplate insert = new SQLTemplate(
                     Artist.class,
-                    "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, SMALLINT_UNSIGNED) VALUES
(1, 'A', 32768)");
+                    "INSERT INTO ARTIST (ARTIST_ID, ARTIST_NAME, SMALLINT_UNSIGNED) VALUES
(1, 'A', 33000)");
 
             ObjectContext context = createDataContext();
             context.performGenericQuery(insert);
-            
+
             SQLTemplate select = new SQLTemplate(Artist.class, "SELECT * FROM ARTIST");
             select.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
-            
-            
+
             List<Artist> results = context.performQuery(select);
             assertEquals(1, results.size());
-            assertEquals(32768, results.get(0).readProperty("smallintUnsigned"));
+            assertEquals(33000, results.get(0).readProperty("smallintUnsigned"));
         }
     }
 }



Mime
View raw message