From 5ccabc7bd1f824cf205df0721038d197f1469421 Mon Sep 17 00:00:00 2001 From: filipe Date: Fri, 7 Jun 2024 15:31:27 -0300 Subject: [PATCH] fix: change priority method to ignore databases that are not databricks --- .../jvm/ForeignKeySnapshotGeneratorDatabricks.java | 11 ++++++++++- .../jvm/ResultSetConstraintsExtractorDatabricks.java | 5 ++--- .../UniqueConstraintSnapshotGeneratorDatabricks.java | 10 +++++----- .../snapshot/jvm/ViewSnapshotGeneratorDatabricks.java | 8 ++++---- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/liquibase/ext/databricks/snapshot/jvm/ForeignKeySnapshotGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/snapshot/jvm/ForeignKeySnapshotGeneratorDatabricks.java index 33a9c37a..d9a49860 100644 --- a/src/main/java/liquibase/ext/databricks/snapshot/jvm/ForeignKeySnapshotGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/snapshot/jvm/ForeignKeySnapshotGeneratorDatabricks.java @@ -40,6 +40,15 @@ public class ForeignKeySnapshotGeneratorDatabricks extends ForeignKeySnapshotGen public static final String METADATA_DELETE_RULE = "DELETE_RULE"; + @Override + public int getPriority(Class objectType, Database database) { + if (database instanceof DatabricksDatabase) { + return super.getPriority(objectType, database) + PRIORITY_DATABASE; + } else { + return PRIORITY_NONE; + } + } + @Override public Class[] replaces() { return new Class[]{ForeignKeySnapshotGenerator.class}; @@ -289,4 +298,4 @@ private boolean driverUsesSpFkeys(Database database) throws DatabaseException { } } -} \ No newline at end of file +} diff --git a/src/main/java/liquibase/ext/databricks/snapshot/jvm/ResultSetConstraintsExtractorDatabricks.java b/src/main/java/liquibase/ext/databricks/snapshot/jvm/ResultSetConstraintsExtractorDatabricks.java index c3c51a31..32bf6b52 100644 --- a/src/main/java/liquibase/ext/databricks/snapshot/jvm/ResultSetConstraintsExtractorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/snapshot/jvm/ResultSetConstraintsExtractorDatabricks.java @@ -5,12 +5,11 @@ import liquibase.database.Database; import liquibase.exception.DatabaseException; import liquibase.snapshot.CachedRow; -import liquibase.snapshot.DatabaseSnapshot;; +import liquibase.snapshot.DatabaseSnapshot; import liquibase.structure.core.Schema; import java.sql.SQLException; import java.util.List; -import liquibase.ext.databricks.snapshot.jvm.ResultSetCacheDatabricks; public class ResultSetConstraintsExtractorDatabricks extends ResultSetCacheDatabricks.SingleResultSetExtractor { @@ -79,4 +78,4 @@ private String createSql(String catalog, String schema, String table) { return sql; } -} \ No newline at end of file +} diff --git a/src/main/java/liquibase/ext/databricks/snapshot/jvm/UniqueConstraintSnapshotGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/snapshot/jvm/UniqueConstraintSnapshotGeneratorDatabricks.java index fe34237a..adbf5121 100644 --- a/src/main/java/liquibase/ext/databricks/snapshot/jvm/UniqueConstraintSnapshotGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/snapshot/jvm/UniqueConstraintSnapshotGeneratorDatabricks.java @@ -20,11 +20,11 @@ public class UniqueConstraintSnapshotGeneratorDatabricks extends UniqueConstrain @Override public int getPriority(Class objectType, Database database) { - int priority = super.getPriority(objectType, database); - if (priority > PRIORITY_NONE && database instanceof DatabricksDatabase) { - priority += DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + if (database instanceof DatabricksDatabase) { + return super.getPriority(objectType, database) + PRIORITY_DATABASE; + } else { + return PRIORITY_NONE; } - return priority; } @Override @@ -62,4 +62,4 @@ protected List listConstraints(Table table, DatabaseSnapshot snapshot } return Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database).queryForList(new RawSqlStatement(sql)); - }} \ No newline at end of file + }} diff --git a/src/main/java/liquibase/ext/databricks/snapshot/jvm/ViewSnapshotGeneratorDatabricks.java b/src/main/java/liquibase/ext/databricks/snapshot/jvm/ViewSnapshotGeneratorDatabricks.java index 82faa7eb..05301ab9 100644 --- a/src/main/java/liquibase/ext/databricks/snapshot/jvm/ViewSnapshotGeneratorDatabricks.java +++ b/src/main/java/liquibase/ext/databricks/snapshot/jvm/ViewSnapshotGeneratorDatabricks.java @@ -27,11 +27,11 @@ public class ViewSnapshotGeneratorDatabricks extends ViewSnapshotGenerator { @Override public int getPriority(Class objectType, Database database) { - int priority = super.getPriority(objectType, database); - if (priority > PRIORITY_NONE && database instanceof DatabricksDatabase) { - priority += DatabricksDatabase.DATABRICKS_PRIORITY_DATABASE; + if (database instanceof DatabricksDatabase) { + return super.getPriority(objectType, database) + PRIORITY_DATABASE; + } else { + return PRIORITY_NONE; } - return priority; } @Override