schemacrawler / SchemaCrawler

Free database schema discovery and comprehension tool
http://www.schemacrawler.com/
Other
1.62k stars 200 forks source link

NamedObjectComparisonStrategy in schemacrawler-diff doesn't seem to work #100

Closed chrycheng closed 7 years ago

chrycheng commented 7 years ago

It's mapped to handle NamedObject instances but as far as I can tell it doesn't get retrieved because NamedObject is an interface and the actual type of the instance (e.g., MutableTable, etc.) is used to look up ComparisonStrategys in ComparisonService. To further confirm, I added System.out.println calls to NamedObjectComparisonStrategy::compare (see following diff) which did not appear in the console output.

diff --git a/schemacrawler-diff/src/main/java/schemacrawler/tools/integration/objectdiffer/SchemaCrawlerDifferBuilder.java b/schemacrawler-diff/src/main/java/schemacrawler/tools/integration/objectdiffer/SchemaCrawlerDifferBuilder.java
index bef19ab..b793b70 100644
--- a/schemacrawler-diff/src/main/java/schemacrawler/tools/integration/objectdiffer/SchemaCrawlerDifferBuilder.java
+++ b/schemacrawler-diff/src/main/java/schemacrawler/tools/integration/objectdiffer/SchemaCrawlerDifferBuilder.java
@@ -45,6 +45,7 @@ public class SchemaCrawlerDifferBuilder
     public void compare(final DiffNode node, final Class<?> type,
                         final Object working, final Object base)
     {
+      System.out.printf("Comparing %s and %s.\n", working, base);
       if (NamedObject.class.isAssignableFrom(type))
       {
         if (isEqual((NamedObject) working, (NamedObject) base))
chrycheng commented 7 years ago

Actually, removing the mapping doesn't seem to affect the outcome of the test as it still passes.

diff --git a/schemacrawler-diff/src/main/java/schemacrawler/tools/integration/objectdiffer/SchemaCrawlerDifferBuilder.java b/schemacrawler-diff/src/main/java/schemacrawler/tools/integration/objectdiffer/SchemaCrawlerDifferBuilder.java
index bef19ab..58eeed2 100644
--- a/schemacrawler-diff/src/main/java/schemacrawler/tools/integration/objectdiffer/SchemaCrawlerDifferBuilder.java
+++ b/schemacrawler-diff/src/main/java/schemacrawler/tools/integration/objectdiffer/SchemaCrawlerDifferBuilder.java
@@ -82,8 +82,6 @@ public class SchemaCrawlerDifferBuilder
       .propertyName("exportedForeignKeys");
     objectDifferBuilder.inclusion().exclude()
       .propertyName("importedForeignKeys");
-    objectDifferBuilder.comparison().ofType(NamedObject.class)
-      .toUse(new NamedObjectComparisonStrategy());
     objectDifferBuilder.inclusion().exclude().propertyName("deferrable");
     objectDifferBuilder.inclusion().exclude().propertyName("initiallyDeferred");
   }