Skip to content

Commit

Permalink
0001556: Wildcard triggers for tables with same name in different cat…
Browse files Browse the repository at this point in the history
…alog/schema. Fixes 0001556.
  • Loading branch information
erilong committed Feb 3, 2014
1 parent 6ef8cfd commit f30d134
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -1202,7 +1202,7 @@ protected Set<Table> getTablesForTrigger(Trigger trigger, List<Trigger> triggers
for (Table table : tableArray) {
if (trigger.matches(table, platform.getDefaultCatalog(),
platform.getDefaultSchema(), ignoreCase)
&& !containsExactMatchForSourceTableName(table.getName(), triggers,
&& !containsExactMatchForSourceTableName(table, triggers,
ignoreCase)
&& !table.getName().toLowerCase().startsWith(tablePrefix)) {
tables.add(table);
Expand All @@ -1222,12 +1222,16 @@ protected Set<Table> getTablesForTrigger(Trigger trigger, List<Trigger> triggers
return tables;
}

private boolean containsExactMatchForSourceTableName(String tableName, List<Trigger> triggers,
private boolean containsExactMatchForSourceTableName(Table table, List<Trigger> triggers,
boolean ignoreCase) {
for (Trigger trigger : triggers) {
if (trigger.getSourceTableName().equals(tableName)) {
String sourceCatalogName = trigger.getSourceCatalogName() != null ? trigger.getSourceCatalogName() : platform.getDefaultCatalog();
String sourceSchemaName = trigger.getSourceSchemaName() != null ? trigger.getSourceSchemaName() : platform.getDefaultSchema();
if (trigger.getSourceTableName().equals(table.getName())
&& sourceCatalogName.equals(table.getCatalog()) && sourceSchemaName.equals(table.getSchema())) {
return true;
} else if (ignoreCase && trigger.getSourceTableName().equalsIgnoreCase(tableName)) {
} else if (ignoreCase && trigger.getSourceTableName().equalsIgnoreCase(table.getName())
&& sourceCatalogName.equalsIgnoreCase(table.getCatalog()) && sourceSchemaName.equalsIgnoreCase(table.getSchema())) {
return true;
}
}
Expand Down

0 comments on commit f30d134

Please sign in to comment.