From d1712cf371bd4c0a87d03415eedf58c37f2221a6 Mon Sep 17 00:00:00 2001 From: Joy A Date: Mon, 15 Apr 2024 15:27:53 +0530 Subject: [PATCH] #84 | Escape schemaName in other usages --- .../org/avniproject/etl/domain/metadata/diff/AddColumn.java | 2 ++ .../org/avniproject/etl/domain/metadata/diff/AddIndex.java | 2 ++ .../avniproject/etl/domain/metadata/diff/CreateTable.java | 2 +- .../avniproject/etl/domain/metadata/diff/RenameColumn.java | 2 ++ .../avniproject/etl/domain/metadata/diff/RenameIndex.java | 2 ++ .../avniproject/etl/domain/metadata/diff/RenameTable.java | 5 +++-- 6 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/avniproject/etl/domain/metadata/diff/AddColumn.java b/src/main/java/org/avniproject/etl/domain/metadata/diff/AddColumn.java index e22361b..056e947 100644 --- a/src/main/java/org/avniproject/etl/domain/metadata/diff/AddColumn.java +++ b/src/main/java/org/avniproject/etl/domain/metadata/diff/AddColumn.java @@ -22,7 +22,9 @@ public AddColumn(String tableName, Column column) { public String getSql() { String alter_table_add_column = new StringBuffer() .append("alter table ") + .append(QUOTE) .append(OrgIdentityContextHolder.getDbSchema()) + .append(QUOTE) .append(DOT) .append(tableName) .append(" add column ") diff --git a/src/main/java/org/avniproject/etl/domain/metadata/diff/AddIndex.java b/src/main/java/org/avniproject/etl/domain/metadata/diff/AddIndex.java index 559ba03..bb12024 100644 --- a/src/main/java/org/avniproject/etl/domain/metadata/diff/AddIndex.java +++ b/src/main/java/org/avniproject/etl/domain/metadata/diff/AddIndex.java @@ -23,7 +23,9 @@ public String getSql() { .append(name) .append(QUOTE) .append(" on ") + .append(QUOTE) .append(OrgIdentityContextHolder.getDbSchema()) + .append(QUOTE) .append(DOT) .append(QUOTE) .append(tableName) diff --git a/src/main/java/org/avniproject/etl/domain/metadata/diff/CreateTable.java b/src/main/java/org/avniproject/etl/domain/metadata/diff/CreateTable.java index f4ff8cd..e1bedd9 100644 --- a/src/main/java/org/avniproject/etl/domain/metadata/diff/CreateTable.java +++ b/src/main/java/org/avniproject/etl/domain/metadata/diff/CreateTable.java @@ -60,7 +60,7 @@ private StringBuilder grantPermissionsToObject(String dbSchema, String user, Str } private String getTableName() { - return new StringBuilder().append(OrgIdentityContextHolder.getDbSchema()) + return new StringBuilder().append(QUOTE).append(OrgIdentityContextHolder.getDbSchema()).append(QUOTE) .append(DOT) .append(name) .toString(); diff --git a/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameColumn.java b/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameColumn.java index 020139a..4f48443 100644 --- a/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameColumn.java +++ b/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameColumn.java @@ -22,7 +22,9 @@ public RenameColumn(String tableName, String oldName, String newName) { public String getSql() { String alter_table_rename_col = new StringBuffer() .append("alter table ") + .append(QUOTE) .append(OrgIdentityContextHolder.getDbSchema()) + .append(QUOTE) .append(DOT) .append(tableName) .append(" rename column ") diff --git a/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameIndex.java b/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameIndex.java index 90d6899..36abf88 100644 --- a/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameIndex.java +++ b/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameIndex.java @@ -17,7 +17,9 @@ public RenameIndex(String oldName, String newName) { public String getSql() { return new StringBuffer() .append("ALTER INDEX ") + .append(QUOTE) .append(OrgIdentityContextHolder.getDbSchema()) + .append(QUOTE) .append(DOT) .append(QUOTE) .append(oldName) diff --git a/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameTable.java b/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameTable.java index 6b1be3a..7896c2a 100644 --- a/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameTable.java +++ b/src/main/java/org/avniproject/etl/domain/metadata/diff/RenameTable.java @@ -2,8 +2,7 @@ import org.avniproject.etl.domain.OrgIdentityContextHolder; -import static org.avniproject.etl.domain.metadata.diff.Strings.DOT; -import static org.avniproject.etl.domain.metadata.diff.Strings.END_STATEMENT; +import static org.avniproject.etl.domain.metadata.diff.Strings.*; public class RenameTable implements Diff { private final String oldName; @@ -18,7 +17,9 @@ public RenameTable(String oldName, String newName) { public String getSql() { return new StringBuffer() .append("alter table ") + .append(QUOTE) .append(OrgIdentityContextHolder.getDbSchema()) + .append(QUOTE) .append(DOT) .append(oldName) .append(" rename to ")