Skip to content

Commit

Permalink
Merge pull request #364 from liquibase/DAT-18828
Browse files Browse the repository at this point in the history
Escape schema name in query DAT-18828
  • Loading branch information
suryaaki2 authored Jan 10, 2025
2 parents 5de4e98 + 9966784 commit 747468c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ public class BigQueryChangedTableChangeGenerator extends ChangedTableChangeGener

@Override
public int getPriority(Class<? extends DatabaseObject> objectType, Database database) {
if (! (database instanceof BigQueryDatabase)) {
return PRIORITY_NONE;
}
int priority = super.getPriority(objectType, database);
if (database instanceof BigQueryDatabase) {
priority += PRIORITY_DATABASE;
if (priority == PRIORITY_NONE) {
return priority;
}
priority += PRIORITY_DATABASE;
return priority;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, ?>> maps = executor.queryForList(new RawParameterizedSqlStatement(keyColumnUsageStatement, example.getName()));
String columnName;
Expand Down Expand Up @@ -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<Map<String, ?>> maps = executor.queryForList(new RawParameterizedSqlStatement(tableConstraintsStatement, table.getName()));

for (Map<String, ?> map : maps) {
Expand Down

0 comments on commit 747468c

Please sign in to comment.