From 560bf09c2d6ea79e5f9ab724c593da65a65a9ecf Mon Sep 17 00:00:00 2001 From: Wesley Willard Date: Mon, 30 Dec 2024 13:48:36 -0600 Subject: [PATCH 1/4] Escape schema name in query DAT-18828 --- .../snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/liquibase/ext/bigquery/snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java b/src/main/java/liquibase/ext/bigquery/snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java index d988edb..c991ece 100644 --- a/src/main/java/liquibase/ext/bigquery/snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java +++ b/src/main/java/liquibase/ext/bigquery/snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java @@ -84,7 +84,7 @@ protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) thro Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database); String tableConstraintsStatement = String.format("SELECT * FROM %s.INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE " + - "CONSTRAINT_TYPE = 'PRIMARY KEY' AND table_name = ?", table.getSchema().getName()); + "CONSTRAINT_TYPE = 'PRIMARY KEY' AND table_name = ?", database.escapeObjectName(table.getSchema().getName(), Schema.class)); List> maps = executor.queryForList(new RawParameterizedSqlStatement(tableConstraintsStatement, table.getName())); for (Map map : maps) { From 4d2770bd7ae19208616982f1a5fcbef121acdb37 Mon Sep 17 00:00:00 2001 From: Wesley Willard Date: Fri, 3 Jan 2025 13:57:19 -0600 Subject: [PATCH 2/4] DAT-18828 Add another escape --- .../snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/liquibase/ext/bigquery/snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java b/src/main/java/liquibase/ext/bigquery/snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java index c991ece..20ebab4 100644 --- a/src/main/java/liquibase/ext/bigquery/snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java +++ b/src/main/java/liquibase/ext/bigquery/snapshot/jvm/BigQueryPrimaryKeySnapshotGenerator.java @@ -44,7 +44,7 @@ protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot PrimaryKey returnKey = null; String keyColumnUsageStatement = String.format("SELECT * FROM %s.INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE CONSTRAINT_NAME = ?", - example.getSchema().getName()); + database.escapeObjectName(example.getSchema().getName(), Schema.class)); Executor executor = Scope.getCurrentScope().getSingleton(ExecutorService.class).getExecutor("jdbc", database); List> maps = executor.queryForList(new RawParameterizedSqlStatement(keyColumnUsageStatement, example.getName())); String columnName; From 66d503f4e5372772f6e7e3789f336efac4900e52 Mon Sep 17 00:00:00 2001 From: Wesley Willard Date: Mon, 6 Jan 2025 08:42:51 -0600 Subject: [PATCH 3/4] DAT-18828 Rework getPriority to handle diffChangelog --- .../changelog/core/BigQueryChangedTableChangeGenerator.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/liquibase/ext/bigquery/diff/output/changelog/core/BigQueryChangedTableChangeGenerator.java b/src/main/java/liquibase/ext/bigquery/diff/output/changelog/core/BigQueryChangedTableChangeGenerator.java index 1456dc3..ac189ac 100644 --- a/src/main/java/liquibase/ext/bigquery/diff/output/changelog/core/BigQueryChangedTableChangeGenerator.java +++ b/src/main/java/liquibase/ext/bigquery/diff/output/changelog/core/BigQueryChangedTableChangeGenerator.java @@ -18,6 +18,9 @@ public class BigQueryChangedTableChangeGenerator extends ChangedTableChangeGener @Override public int getPriority(Class objectType, Database database) { int priority = super.getPriority(objectType, database); + if (priority == PRIORITY_NONE) { + return priority; + } if (database instanceof BigQueryDatabase) { priority += PRIORITY_DATABASE; } From 9966784d41356f4c3d950e4eb5238dfaa743210f Mon Sep 17 00:00:00 2001 From: Wesley Willard Date: Mon, 6 Jan 2025 08:54:29 -0600 Subject: [PATCH 4/4] DAT-18828 Rework last change --- .../core/BigQueryChangedTableChangeGenerator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/liquibase/ext/bigquery/diff/output/changelog/core/BigQueryChangedTableChangeGenerator.java b/src/main/java/liquibase/ext/bigquery/diff/output/changelog/core/BigQueryChangedTableChangeGenerator.java index ac189ac..4ccdfaf 100644 --- a/src/main/java/liquibase/ext/bigquery/diff/output/changelog/core/BigQueryChangedTableChangeGenerator.java +++ b/src/main/java/liquibase/ext/bigquery/diff/output/changelog/core/BigQueryChangedTableChangeGenerator.java @@ -17,13 +17,14 @@ public class BigQueryChangedTableChangeGenerator extends ChangedTableChangeGener @Override public int getPriority(Class objectType, Database database) { + if (! (database instanceof BigQueryDatabase)) { + return PRIORITY_NONE; + } int priority = super.getPriority(objectType, database); if (priority == PRIORITY_NONE) { return priority; } - if (database instanceof BigQueryDatabase) { - priority += PRIORITY_DATABASE; - } + priority += PRIORITY_DATABASE; return priority; }