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 در آز٠اÛشگاÙâÙØ§Û ØªØÙÛÙØ§ØªÛ Ø¹ÙÙ Û Ø´Ø±Ú©Øª بÙئÛÙÚ¯ کار Ù Ûâکرد]. با اÛÙ ÙجÙد Ù¾Ùداشت٠درخت Ø¨Û Ø¨Ù Ø¹ÙÙا٠درخت \"بÙÛÙر\" ÙÛز درخÙر است.[Û²]"); }