fix tests for MySQL and SQLite

Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/e14aea35
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/e14aea35
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/e14aea35

Branch: refs/heads/master
Commit: e14aea35eed951d0bd8b3f14fdf4c939983282e7
Parents: a7b549a
Author: kolonitsky <alex.kolonit...@gmail.com>
Authored: Tue Feb 10 22:40:35 2015 +0300
Committer: kolonitsky <alex.kolonit...@gmail.com>
Committed: Tue Feb 10 22:40:35 2015 +0300

----------------------------------------------------------------------
 .../apache/cayenne/dba/mysql/MySQLAdapter.java  | 19 +++++++++++++++++++
 .../cayenne/dba/sqlite/SQLiteAdapter.java       | 20 ++++++++++++++++++++
 .../org/apache/cayenne/access/DbLoaderIT.java   |  5 -----
 .../cayenne/access/ReturnTypesMappingIT.java    |  2 +-
 4 files changed, 40 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/e14aea35/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java 
b/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
index d5f7e2a..1a37f36 100644
--- 
a/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
+++ 
b/cayenne-server/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
@@ -19,6 +19,8 @@
 
 package org.apache.cayenne.dba.mysql;
 
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -205,6 +207,23 @@ public class MySQLAdapter extends JdbcAdapter {
         return super.buildAttribute(name, typeName, type, size, precision, 
allowNulls);
     }
 
+    @Override
+    public void bindParameter(PreparedStatement statement, Object object, int 
pos, int sqlType, int scale) throws SQLException, Exception {
+        super.bindParameter(statement, object, pos, mapNTypes(sqlType), scale);
+    }
+
+    private int mapNTypes(int sqlType) {
+        switch (sqlType) {
+            case Types.NCHAR : return Types.CHAR;
+            case Types.NCLOB : return Types.CLOB;
+            case Types.NVARCHAR : return Types.VARCHAR;
+            case Types.LONGNVARCHAR : return Types.LONGVARCHAR;
+
+            default:
+                return sqlType;
+        }
+    }
+
     /**
      * Creates and returns a primary key generator. Overrides superclass
      * implementation to return an instance of MySQLPkGenerator that does the

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e14aea35/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java 
b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
index 4873db8..4536148 100644
--- 
a/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
+++ 
b/cayenne-server/src/main/java/org/apache/cayenne/dba/sqlite/SQLiteAdapter.java
@@ -18,6 +18,9 @@
  ****************************************************************/
 package org.apache.cayenne.dba.sqlite;
 
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.GregorianCalendar;
@@ -98,6 +101,23 @@ public class SQLiteAdapter extends JdbcAdapter {
         return query.createSQLAction(new SQLiteActionBuilder(node));
     }
 
+    @Override
+    public void bindParameter(PreparedStatement statement, Object object, int 
pos, int sqlType, int scale) throws SQLException, Exception {
+        super.bindParameter(statement, object, pos, mapNTypes(sqlType), scale);
+    }
+
+    private int mapNTypes(int sqlType) {
+        switch (sqlType) {
+            case Types.NCHAR : return Types.CHAR;
+            case Types.NCLOB : return Types.CLOB;
+            case Types.NVARCHAR : return Types.VARCHAR;
+            case Types.LONGNVARCHAR : return Types.LONGVARCHAR;
+
+            default:
+                return sqlType;
+        }
+    }
+
     /**
      * Appends AUTOINCREMENT clause to the column definition for generated 
columns.
      */

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e14aea35/cayenne-server/src/test/java/org/apache/cayenne/access/DbLoaderIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/access/DbLoaderIT.java 
b/cayenne-server/src/test/java/org/apache/cayenne/access/DbLoaderIT.java
index 0132dff..206c3aa 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/DbLoaderIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/DbLoaderIT.java
@@ -237,11 +237,6 @@ public class DbLoaderIT extends ServerCase {
         assertNotNull("Null 'ARTIST' entity, other DbEntities: " + 
map.getDbEntityMap(), dae);
         assertEquals("ARTIST", dae.getName().toUpperCase());
 
-        if (accessStackAdapter.supportsCatalogs()) {
-            assertNotNull(dae.getCatalog());
-            assertEquals("CAYENNE", dae.getCatalog().toUpperCase());
-        }
-
         DbAttribute a = getDbAttribute(dae, "ARTIST_ID");
         assertNotNull(a);
         assertTrue(a.isPrimaryKey());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/e14aea35/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
----------------------------------------------------------------------
diff --git 
a/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
 
b/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
index b5d7b95..651d37c 100644
--- 
a/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
+++ 
b/cayenne-server/src/test/java/org/apache/cayenne/access/ReturnTypesMappingIT.java
@@ -330,7 +330,7 @@ public class ReturnTypesMappingIT extends ServerCase {
             ReturnTypesMapLobs1 test = 
context.newObject(ReturnTypesMapLobs1.class);
 
             StringBuilder buffer = new StringBuilder();
-            for (int i = 0; i < 10000; i++) {
+            for (int i = 0; i < 1000; i++) {
                 buffer.append("رودالف بیر و دد مک‌کرِیت 
درخت بی را زمانی که در شرکت بوئینگ [۱]، مشغول 
به کار بودند ابداع نمودند، اما حرف B واقعاً\" 
از کجا آمده؟ داگلاس کامر یک سری از احتمالات 
را پیشنهاد کرد:\n" +
                         "\"Balanced,\" \"Broad,\" یا \"Bushy\" ممکن 
است استفاده شده‌باشند [چون همهٔ برگ‌ها در 
یک سطح قرار دارند]. دیگران اظهار داشتند که 
حرف \"B\" از کلمهٔ بوئینگ گرفته شده است [به این 
دلیل که پدیدآوردنده درسال 1972 در آزم
ایشگاه‌های تحقیقاتی علمی شرکت بوئینگ کار م
ی‌کرد]. با این وجود پنداشتن درخت بی به عنوان 
درخت \"بِیِر\" نیز درخور است.[۲]");
             }

Reply via email to