cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2440 cdbimport: allow cross-schema relationships fix tests
Date Fri, 01 Jun 2018 09:12:16 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 85805afca -> db8a4a577


CAY-2440 cdbimport: allow cross-schema relationships
  fix tests


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

Branch: refs/heads/master
Commit: db8a4a577e89326824ae3a1f76c76ad52e29be40
Parents: 85805af
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Fri Jun 1 11:59:50 2018 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Fri Jun 1 11:59:50 2018 +0300

----------------------------------------------------------------------
 .../dbsync/reverse/dbload/ExportedKey.java      | 22 +++++++++++++++-----
 .../reverse/dbload/ExportedKeyLoaderIT.java     | 17 ++++++++++++---
 2 files changed, 31 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/db8a4a57/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKey.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKey.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKey.java
index 51a5eb6..e8d74b8 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKey.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/dbload/ExportedKey.java
@@ -23,10 +23,10 @@ import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.util.EqualsBuilder;
 import org.apache.cayenne.util.HashCodeBuilder;
 import org.apache.cayenne.util.CompareToBuilder;
+import org.apache.cayenne.util.Util;
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.Objects;
 
 /**
  * A representation of relationship between two tables in database. It can be used for creating
names
@@ -228,12 +228,24 @@ public class ExportedKey implements Comparable {
                 return false;
             }
 
-            if (!Objects.equals(catalog, entity.getCatalog())) {
-                return false;
+            if(Util.isEmptyString(catalog)) {
+                if(!Util.isEmptyString(entity.getCatalog())) {
+                    return false;
+                }
+            } else {
+                if(!catalog.equals(entity.getCatalog())) {
+                    return false;
+                }
             }
 
-            if (!Objects.equals(schema, entity.getSchema())) {
-                return false;
+            if(Util.isEmptyString(schema)) {
+                if(!Util.isEmptyString(entity.getSchema())) {
+                    return false;
+                }
+            } else {
+                if(!schema.equals(entity.getSchema())) {
+                    return false;
+                }
             }
 
             return true;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/db8a4a57/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 812581a..53bcd57 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
@@ -22,6 +22,8 @@ package org.apache.cayenne.dbsync.reverse.dbload;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.junit.Test;
@@ -31,6 +33,9 @@ import static org.junit.Assert.assertNotNull;
 
 public class ExportedKeyLoaderIT extends BaseLoaderIT {
 
+    @Inject
+    DbAdapter adapter;
+
     @Test
     public void testExportedKeyLoad() throws Exception {
         boolean supportsFK = accessStackAdapter.supportsFKConstraints();
@@ -46,19 +51,25 @@ public class ExportedKeyLoaderIT extends BaseLoaderIT {
         String schema = connection.getSchema();
 
         DbEntity artist = getDbEntity("ARTIST");
-        artist.setCatalog(catalog);
+        if(adapter.supportsCatalogsOnReverseEngineering()) {
+            artist.setCatalog(catalog);
+        }
         artist.setSchema(schema);
         DbAttribute artistId = new DbAttribute("ARTIST_ID");
         artist.addAttribute(artistId);
 
         DbEntity gallery = getDbEntity("GALLERY");
-        gallery.setCatalog(catalog);
+        if(adapter.supportsCatalogsOnReverseEngineering()) {
+            gallery.setCatalog(catalog);
+        }
         gallery.setSchema(schema);
         DbAttribute galleryId = new DbAttribute("GALLERY_ID");
         gallery.addAttribute(galleryId);
 
         DbEntity painting = getDbEntity("PAINTING");
-        painting.setCatalog(catalog);
+        if(adapter.supportsCatalogsOnReverseEngineering()) {
+            painting.setCatalog(catalog);
+        }
         painting.setSchema(schema);
         DbAttribute paintingId = new DbAttribute("PAINTING_ID");
         DbAttribute paintingArtistId = new DbAttribute("ARTIST_ID");


Mime
View raw message