cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skolbac...@apache.org
Subject [2/4] cayenne git commit: Fix DataMapMerger case sensitivity issues - can miss relationship and attribute change if name in mixed upper- and lowercase - fix test failures caused by lower- and uppercase names - additional tests - fix test failures for
Date Thu, 22 Dec 2016 13:39:53 GMT
Fix DataMapMerger case sensitivity issues
 - can miss relationship and attribute change if name in mixed upper- and lowercase
 - fix test failures caused by lower- and uppercase names
 - additional tests
 - fix test failures for Postgres (and partially for Oracle and SQLServer but tests needed)


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

Branch: refs/heads/master
Commit: 4d14b7182dad5389c80721c64fefd5895d5290b5
Parents: 65233b2
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Thu Dec 22 15:09:35 2016 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Thu Dec 22 15:09:35 2016 +0300

----------------------------------------------------------------------
 .../cayenne/dbsync/merge/DbAttributeMerger.java |  5 ++
 .../merge/token/db/SetColumnTypeToDb.java       |  8 +++
 .../dbsync/reverse/dbload/DbLoadDataStore.java  |  8 +++
 .../cayenne/dbsync/merge/DataMapMergerTest.java | 74 ++++++++++++++++++++
 .../apache/cayenne/dbsync/merge/MergeCase.java  | 43 +++++++++++-
 .../merge/builders/DbAttributeBuilder.java      |  5 ++
 .../dbsync/reverse/dbload/BaseLoaderIT.java     | 10 ++-
 .../dbsync/reverse/dbload/DbLoaderIT.java       | 17 +++--
 .../reverse/dbload/ExportedKeyLoaderIT.java     | 19 +++--
 .../reverse/dbload/PrimaryKeyLoaderIT.java      |  8 +--
 .../cayenne/unit/OracleUnitDbAdapter.java       | 10 +++
 .../cayenne/unit/PostgresUnitDbAdapter.java     |  4 ++
 .../cayenne/unit/SQLServerUnitDbAdapter.java    |  5 ++
 .../org/apache/cayenne/unit/UnitDbAdapter.java  | 12 ++++
 .../dbimport/testDbAttributeChange.map.xml      | 12 +++-
 .../testDbAttributeChange.map.xml-result        | 11 ++-
 .../tools/dbimport/testDbAttributeChange.sql    |  8 ++-
 17 files changed, 234 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbAttributeMerger.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbAttributeMerger.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbAttributeMerger.java
index 8cdbd16..fcf859d 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbAttributeMerger.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbAttributeMerger.java
@@ -122,6 +122,11 @@ class DbAttributeMerger extends AbstractMerger<DbEntity, DbAttribute>
{
      */
     private boolean needUpdateType(DbAttribute original, DbAttribute imported) {
         if(original.getType() != imported.getType()) {
+            // Decimal and NUMERIC types are effectively equal so skip their interchange
+            if( (original.getType() == Types.DECIMAL || original.getType() == Types.NUMERIC)
&&
+                (imported.getType() == Types.DECIMAL || imported.getType() == Types.NUMERIC))
{
+                return false;
+            }
             return true;
         }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/db/SetColumnTypeToDb.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/db/SetColumnTypeToDb.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/db/SetColumnTypeToDb.java
index 331d550..f03e929 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/db/SetColumnTypeToDb.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/token/db/SetColumnTypeToDb.java
@@ -110,4 +110,12 @@ public class SetColumnTypeToDb extends AbstractToDbToken.Entity {
     public MergerToken createReverse(MergerTokenFactory factory) {
         return factory.createSetColumnTypeToModel(getEntity(), columnNew, columnOriginal);
     }
+
+    public DbAttribute getColumnNew() {
+        return columnNew;
+    }
+
+    public DbAttribute getColumnOriginal() {
+        return columnOriginal;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoadDataStore.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoadDataStore.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoadDataStore.java
index ec06163..c1a6e4c 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoadDataStore.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoadDataStore.java
@@ -43,16 +43,24 @@ public class DbLoadDataStore extends DataMap {
 
     private Map<String, Set<ExportedKey>> exportedKeys = new HashMap<>();
 
+    private Map<String, DbEntity> upperCaseNames = new HashMap<>();
+
     DbLoadDataStore() {
         super("__generated_by_dbloader__");
     }
 
     @Override
+    public DbEntity getDbEntity(String dbEntityName) {
+        return upperCaseNames.get(dbEntityName.toUpperCase());
+    }
+
+    @Override
     public void addDbEntity(DbEntity entity) {
         if(!(entity instanceof DetectedDbEntity)) {
             throw new IllegalArgumentException("Only DetectedDbEntity can be inserted in
this map");
         }
         super.addDbEntity(entity);
+        upperCaseNames.put(entity.getName().toUpperCase(), entity);
     }
 
     DbEntity addDbEntitySafe(DbEntity entity) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/DataMapMergerTest.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/DataMapMergerTest.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/DataMapMergerTest.java
index 5196fa9..aced949 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/DataMapMergerTest.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/DataMapMergerTest.java
@@ -315,6 +315,64 @@ public class DataMapMergerTest {
     }
 
     @Test
+    public void testTableNameUppercaseRelationship() throws Exception {
+        DataMap existing = dataMap().with(
+                dbEntity("TABLE1").attributes(
+                        dbAttr("attr01").typeInt(),
+                        dbAttr("attr02").typeInt()),
+
+                dbEntity("table2").attributes(
+                        dbAttr("attr01").typeInt().primaryKey(),
+                        dbAttr("attr02").typeInt().primaryKey(),
+                        dbAttr("attr03").typeInt().primaryKey())
+        ).join("rel", "TABLE1.attr01", "table2.attr01").build();
+
+        DataMap db = dataMap().with(
+                dbEntity("table1").attributes(
+                        dbAttr("attr01").typeInt(),
+                        dbAttr("attr02").typeInt()),
+
+                dbEntity("table2").attributes(
+                        dbAttr("attr01").typeInt().primaryKey(),
+                        dbAttr("attr02").typeInt().primaryKey(),
+                        dbAttr("attr03").typeInt().primaryKey())
+        ).join("rel", "table1.attr01", "table2.attr01").build();
+
+
+        List<MergerToken> tokens = dbMerger().createMergeTokens(existing, db);
+        assertEquals(0, tokens.size());
+    }
+
+    @Test
+    public void testAttributeNameUppercaseRelationship() throws Exception {
+        DataMap existing = dataMap().with(
+                dbEntity("table1").attributes(
+                        dbAttr("ATTR01").typeInt(),
+                        dbAttr("attr02").typeInt()),
+
+                dbEntity("table2").attributes(
+                        dbAttr("attr01").typeInt().primaryKey(),
+                        dbAttr("attr02").typeInt().primaryKey(),
+                        dbAttr("attr03").typeInt().primaryKey())
+        ).join("rel", "table1.ATTR01", "table2.attr01").build();
+
+        DataMap db = dataMap().with(
+                dbEntity("table1").attributes(
+                        dbAttr("attr01").typeInt(),
+                        dbAttr("attr02").typeInt()),
+
+                dbEntity("table2").attributes(
+                        dbAttr("attr01").typeInt().primaryKey(),
+                        dbAttr("attr02").typeInt().primaryKey(),
+                        dbAttr("attr03").typeInt().primaryKey())
+        ).join("rel", "table1.attr01", "table2.attr01").build();
+
+
+        List<MergerToken> tokens = dbMerger().createMergeTokens(existing, db);
+        assertEquals(0, tokens.size());
+    }
+
+    @Test
     public void testRemoveRelationship() throws Exception {
         DataMap existing = dataMap().with(
             dbEntity("table1").attributes(
@@ -371,6 +429,22 @@ public class DataMapMergerTest {
     }
 
     @Test
+    public void testChangeGeneratedStatus() {
+        DataMap existing = dataMap().with(
+                dbEntity("table1").attributes(
+                        dbAttr("attr01").typeVarchar(10)
+                )).build();
+
+        DataMap db = dataMap().with(
+                dbEntity("table1").attributes(
+                        dbAttr("attr01").typeInt().generated()
+                )).build();
+
+        List<MergerToken> tokens = dbMerger().createMergeTokens(existing, db);
+        assertEquals(2, tokens.size());
+    }
+
+    @Test
     public void testNoChanges() throws Exception {
         DataMap dataMap1 = dataMap().with(
                 dbEntity("table1").attributes(

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/MergeCase.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/MergeCase.java b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/MergeCase.java
index 5c6053e..ef262ee 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/MergeCase.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/MergeCase.java
@@ -22,11 +22,13 @@ import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.configuration.server.ServerRuntime;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.dbsync.merge.context.MergerContext;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider;
 import org.apache.cayenne.dbsync.merge.token.db.AbstractToDbToken;
 import org.apache.cayenne.dbsync.merge.token.MergerToken;
+import org.apache.cayenne.dbsync.merge.token.db.SetColumnTypeToDb;
 import org.apache.cayenne.dbsync.naming.DefaultObjectNameGenerator;
 import org.apache.cayenne.dbsync.naming.NoStemStemmer;
 import org.apache.cayenne.dbsync.reverse.dbload.DbLoader;
@@ -128,7 +130,46 @@ public abstract class MergeCase extends DbSyncCase {
         }
 
         List<MergerToken> tokens = merger().filters(filters).build().createMergeTokens(map,
dbImport);
-        return filterEmpty(tokens);
+        return filter(tokens);
+    }
+
+    private List<MergerToken> filter(List<MergerToken> tokens) {
+        return filterEmptyTypeChange(filterEmpty(tokens));
+    }
+
+    /**
+     * Filter out tokens for db attribute type change when types is same for specific DB
+     */
+    private List<MergerToken> filterEmptyTypeChange(List<MergerToken> tokens)
{
+        List<MergerToken> tokensOut = new ArrayList<>();
+        for(MergerToken token : tokens) {
+            if(!(token instanceof SetColumnTypeToDb)) {
+                tokensOut.add(token);
+                continue;
+            }
+            SetColumnTypeToDb setColumnToDb = (SetColumnTypeToDb)token;
+            int toType = setColumnToDb.getColumnNew().getType();
+            int fromType = setColumnToDb.getColumnOriginal().getType();
+            // filter out conversions between date/time types
+            if(accessStackAdapter.onlyGenericDateType()) {
+                if(isDateTimeType(toType) && isDateTimeType(fromType)){
+                    continue;
+                }
+            }
+            // filter out conversions between numeric types
+            if(accessStackAdapter.onlyGenericNumberType()) {
+                if(TypesMapping.isNumeric(toType) && TypesMapping.isNumeric(fromType))
{
+                    continue;
+                }
+            }
+            tokensOut.add(token);
+        }
+
+        return tokensOut;
+    }
+
+    private static boolean isDateTimeType(int type) {
+        return type == Types.DATE || type == Types.TIME || type == Types.TIMESTAMP;
     }
 
     private List<MergerToken> filterEmpty(List<MergerToken> tokens) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/builders/DbAttributeBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/builders/DbAttributeBuilder.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/builders/DbAttributeBuilder.java
index 2d600f3..99739da 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/builders/DbAttributeBuilder.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/merge/builders/DbAttributeBuilder.java
@@ -94,6 +94,11 @@ public class DbAttributeBuilder extends DefaultBuilder<DbAttribute>
{
         return this;
     }
 
+    public DbAttributeBuilder generated() {
+        obj.setGenerated(true);
+        return this;
+    }
+
     @Override
     public DbAttribute build() {
         if (isEmpty(obj.getName())) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/BaseLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/BaseLoaderIT.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/BaseLoaderIT.java
index 1edc938..a3cf117 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/BaseLoaderIT.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/BaseLoaderIT.java
@@ -72,7 +72,7 @@ public class BaseLoaderIT extends ServerCase {
     void createDbEntities() {
         String[] names = {"ARTIST", "BLOB_TEST", "CLOB_TEST", "GENERATED_COLUMN_TEST"};
         for(String name : names) {
-            createEntity(name);
+            createEntity(nameForDb(name));
         }
     }
 
@@ -88,4 +88,12 @@ public class BaseLoaderIT extends ServerCase {
         }
         return de;
     }
+
+    String nameForDb(String name) {
+        if(accessStackAdapter.isLowerCaseNames()) {
+            return name.toLowerCase();
+        } else {
+            return name.toUpperCase();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java
index d2e87a5..bc8365c 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/DbLoaderIT.java
@@ -82,16 +82,16 @@ public class DbLoaderIT extends ServerCase {
         assertNotNull(artist);
 
         // DbAttribute
-        DbAttribute id = artist.getAttribute("ARTIST_ID");
+        DbAttribute id = getDbAttribute(artist, "ARTIST_ID");
         assertNotNull(id);
         assertTrue(id.isMandatory());
         assertTrue(id.isPrimaryKey());
 
-        DbAttribute name = artist.getAttribute("ARTIST_NAME");
+        DbAttribute name = getDbAttribute(artist,"ARTIST_NAME");
         assertNotNull(name);
         assertTrue(name.isMandatory());
 
-        DbAttribute date = artist.getAttribute("DATE_OF_BIRTH");
+        DbAttribute date = getDbAttribute(artist,"DATE_OF_BIRTH");
         assertNotNull(date);
         assertFalse(date.isMandatory());
 
@@ -100,11 +100,20 @@ public class DbLoaderIT extends ServerCase {
 
         DbRelationship exhibits = artist.getRelationship("artistExhibits");
         assertNotNull(exhibits);
-        assertEquals("ARTIST_EXHIBIT", exhibits.getTargetEntityName());
+        assertEquals("ARTIST_EXHIBIT", exhibits.getTargetEntityName().toUpperCase());
         DbEntity target = exhibits.getTargetEntity();
         assertNotNull(target);
     }
 
+    private DbAttribute getDbAttribute(DbEntity ent, String name) {
+        DbAttribute da = ent.getAttribute(name);
+        // sometimes table names get converted to lowercase
+        if (da == null) {
+            da = ent.getAttribute(name.toLowerCase());
+        }
+
+        return da;
+    }
 
     @Before
     public void before() throws Exception {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java
index 9e74d8c..73ba353 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKeyLoaderIT.java
@@ -38,9 +38,9 @@ public class ExportedKeyLoaderIT extends BaseLoaderIT {
             return;
         }
 
-        createEntity("ARTIST");
-        createEntity("GALLERY");
-        createEntity("PAINTING");
+        createEntity(nameForDb("ARTIST"));
+        createEntity(nameForDb("GALLERY"));
+        createEntity(nameForDb("PAINTING"));
         DbEntity artist = getDbEntity("ARTIST");
         DbAttribute artistId = new DbAttribute("ARTIST_ID");
         artist.addAttribute(artistId);
@@ -65,21 +65,20 @@ public class ExportedKeyLoaderIT extends BaseLoaderIT {
         ExportedKey artistIdFk = findArtistExportedKey();
         assertNotNull(artistIdFk);
 
-        assertEquals("ARTIST", artistIdFk.getPk().getTable());
-        assertEquals("ARTIST_ID", artistIdFk.getPk().getColumn());
+        assertEquals("ARTIST", artistIdFk.getPk().getTable().toUpperCase());
+        assertEquals("ARTIST_ID", artistIdFk.getPk().getColumn().toUpperCase());
 
-        assertEquals("PAINTING", artistIdFk.getFk().getTable());
-        assertEquals("ARTIST_ID", artistIdFk.getFk().getColumn());
+        assertEquals("PAINTING", artistIdFk.getFk().getTable().toUpperCase());
+        assertEquals("ARTIST_ID", artistIdFk.getFk().getColumn().toUpperCase());
     }
 
-    ExportedKey findArtistExportedKey() {
+    private ExportedKey findArtistExportedKey() {
         for(Map.Entry<String, Set<ExportedKey>> entry : store.getExportedKeysEntrySet())
{
-            if(entry.getKey().endsWith(".ARTIST_ID")) {
+            if(entry.getKey().toUpperCase().endsWith(".ARTIST_ID")) {
                 return entry.getValue().iterator().next();
             }
         }
 
         return null;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java
b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java
index 56be301..ae56185 100644
--- a/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java
+++ b/cayenne-dbsync/src/test/java/org/apache/cayenne/dbsync/reverse/dbload/PrimaryKeyLoaderIT.java
@@ -34,10 +34,10 @@ public class PrimaryKeyLoaderIT extends BaseLoaderIT {
     @Test
     public void testPrimaryKeyLoad() throws Exception {
         createDbEntities();
-        DbEntity artist = getDbEntity("ARTIST");
-        DbAttribute artistId = new DbAttribute("ARTIST_ID");
-        DbAttribute artistName = new DbAttribute("ARTIST_NAME");
-        DbAttribute artistId1 = new DbAttribute("ARTIST_ID1");
+        DbEntity artist = getDbEntity(nameForDb("ARTIST"));
+        DbAttribute artistId = new DbAttribute(nameForDb("ARTIST_ID"));
+        DbAttribute artistName = new DbAttribute(nameForDb("ARTIST_NAME"));
+        DbAttribute artistId1 = new DbAttribute(nameForDb("ARTIST_ID1"));
 
         artist.addAttribute(artistId);
         artist.addAttribute(artistName);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
index f0ebb94..9cb93fb 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/OracleUnitDbAdapter.java
@@ -120,4 +120,14 @@ public class OracleUnitDbAdapter extends UnitDbAdapter {
             proc.setReturningValue(true);
         }
     }
+
+    @Override
+    public boolean onlyGenericDateType() {
+        return true;
+    }
+
+    @Override
+    public boolean onlyGenericNumberType() {
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-server/src/test/java/org/apache/cayenne/unit/PostgresUnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/PostgresUnitDbAdapter.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/PostgresUnitDbAdapter.java
index 4182054..1843bc2 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/PostgresUnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/PostgresUnitDbAdapter.java
@@ -62,6 +62,10 @@ public class PostgresUnitDbAdapter extends UnitDbAdapter {
         }
     }
 
+    public boolean isLowerCaseNames() {
+        return true;
+    }
+
     @Override
     public boolean supportsGeneratedKeysDrop() {
         return true;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
index 5315d12..6c03130 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/SQLServerUnitDbAdapter.java
@@ -63,6 +63,11 @@ public class SQLServerUnitDbAdapter extends SybaseUnitDbAdapter {
         return true;
     }
 
+    @Override
+    public boolean onlyGenericDateType() {
+        return true;
+    }
+
     // The code below was used with SQLServer <= 2005 to turn of autogenerated
     // keys.
     // Modern SQLServer driver supports autogen keys just fine.

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java b/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
index 2bf63e0..445de16 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
@@ -347,6 +347,18 @@ public class UnitDbAdapter {
         return constraintMap;
     }
 
+    public boolean isLowerCaseNames() {
+        return false;
+    }
+
+    public boolean onlyGenericNumberType() {
+        return false;
+    }
+
+    public boolean onlyGenericDateType() {
+        return false;
+    }
+
     public boolean supportsNullBoolean() {
         return true;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml
index dc09869..759090a 100644
--- a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml
@@ -35,7 +35,7 @@
         <db-attribute name="COL4" type="VARCHAR" length="25"/>
         <db-attribute name="COL5" type="DATE" length="10"/>
         <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"
length="10"/>
-        <db-attribute name="PARENT_ID" type="CHAR" length="25"/>
+        <db-attribute name="parent_id" type="CHAR" length="25"/>
     </db-entity>
     <obj-entity name="Child" className="Child" dbEntityName="CHILD">
         <obj-attribute name="col3" type="java.math.BigDecimal" db-attribute-path="COL3"/>
@@ -49,4 +49,14 @@
         <obj-attribute name="col4" type="java.lang.String" db-attribute-path="COL4"/>
         <obj-attribute name="col5" type="java.util.Date" db-attribute-path="COL5"/>
     </obj-entity>
+
+    <db-relationship name="parent" source="CHILD" target="parent" toMany="false">
+        <db-attribute-pair source="parent_id" target="ID"/>
+    </db-relationship>
+    <db-relationship name="children" source="parent" target="CHILD" toMany="true">
+        <db-attribute-pair source="ID" target="parent_id"/>
+    </db-relationship>
+
+    <obj-relationship name="parent" source="Child" target="Parent" deleteRule="Nullify"
db-relationship-path="parent"/>
+    <obj-relationship name="children" source="Parent" target="Child" deleteRule="Deny"
db-relationship-path="children"/>
 </data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml-result
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml-result
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml-result
index 441b533..c53bde2 100644
--- a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml-result
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.map.xml-result
@@ -28,9 +28,9 @@
         <db-attribute name="COL4" type="VARCHAR" length="25"/>
         <db-attribute name="COL5" type="DATE" length="10"/>
         <db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"
length="10"/>
-        <db-attribute name="PARENT_ID" type="CHAR" length="25"/>
         <db-attribute name="col1" type="DOUBLE" length="52"/>
         <db-attribute name="col2" type="CHAR" length="25"/>
+        <db-attribute name="parent_id" type="INTEGER" length="10"/>
     </db-entity>
     <db-entity name="parent" schema="SCHEMA_01">
         <db-attribute name="COL2" type="CHAR" length="20"/>
@@ -51,5 +51,12 @@
         <obj-attribute name="col4" type="java.lang.String" db-attribute-path="COL4"/>
         <obj-attribute name="col5" type="java.util.Date" db-attribute-path="COL5"/>
     </obj-entity>
-
+    <db-relationship name="parent" source="CHILD" target="parent" toMany="false">
+        <db-attribute-pair source="parent_id" target="ID"/>
+    </db-relationship>
+    <db-relationship name="children" source="parent" target="CHILD" toMany="true">
+        <db-attribute-pair source="ID" target="parent_id"/>
+    </db-relationship>
+    <obj-relationship name="parent" source="Child" target="Parent" deleteRule="Nullify"
db-relationship-path="parent"/>
+    <obj-relationship name="children" source="Parent" target="Child" deleteRule="Deny"
db-relationship-path="children"/>
 </data-map>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4d14b718/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.sql
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.sql
b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.sql
index 6a2800e..c93c802 100644
--- a/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.sql
+++ b/plugins/maven-cayenne-plugin/src/test/resources/org/apache/cayenne/tools/dbimport/testDbAttributeChange.sql
@@ -31,7 +31,7 @@ CREATE TABLE schema_01.parent (
 
 CREATE TABLE schema_01.child (
   id INTEGER NOT NULL,
-  Parent_id CHAR(25),
+  parent_id INTEGER,
   COL1 FLOAT,
   COL2 CHAR(25),
   COL3 DECIMAL(5,1),
@@ -39,4 +39,8 @@ CREATE TABLE schema_01.child (
   COL5 DATE,
 
   PRIMARY KEY (id)
-);
\ No newline at end of file
+);
+
+ALTER TABLE schema_01.child
+    ADD FOREIGN KEY (parent_id)
+    REFERENCES schema_01.parent (id);
\ No newline at end of file


Mime
View raw message