Skip to content

Commit

Permalink
0000709: Wildcard table lookup should respect the db.metadata.ignore.…
Browse files Browse the repository at this point in the history
…case property
  • Loading branch information
chenson42 committed Jul 12, 2012
1 parent c02b514 commit 231af95
Showing 1 changed file with 9 additions and 4 deletions.
Expand Up @@ -856,6 +856,9 @@ protected Set<Table> getTablesForTrigger(Trigger trigger, List<Trigger> triggers
Set<Table> tables = new HashSet<Table>();

if (trigger.isSourceTableNameWildcarded()) {
boolean ignoreCase = this.parameterService
.is(ParameterConstants.DB_METADATA_IGNORE_CASE);

Database database = symmetricDialect.getPlatform().readDatabase(
trigger.getSourceCatalogName(), trigger.getSourceSchemaName(),
new String[] { "TABLE" });
Expand All @@ -864,8 +867,8 @@ protected Set<Table> getTablesForTrigger(Trigger trigger, List<Trigger> triggers
String[] wildcardTokens = trigger.getSourceTableName().split(",");
for (String wildcardToken : wildcardTokens) {
for (Table table : tableArray) {
if (FormatUtils.isWildCardMatch(table.getName(), wildcardToken)
&& !containsExactMatchForSourceTableName(table.getName(), triggers)
if (FormatUtils.isWildCardMatch(table.getName(), wildcardToken, ignoreCase)
&& !containsExactMatchForSourceTableName(table.getName(), triggers, ignoreCase)
&& !table.getName().toLowerCase().startsWith(tablePrefix)) {
tables.add(table);
} else {
Expand All @@ -884,10 +887,12 @@ protected Set<Table> getTablesForTrigger(Trigger trigger, List<Trigger> triggers
return tables;
}

private boolean containsExactMatchForSourceTableName(String tableName, List<Trigger> triggers) {
private boolean containsExactMatchForSourceTableName(String tableName, List<Trigger> triggers, boolean ignoreCase) {
for (Trigger trigger : triggers) {
if (trigger.getSourceTableName().equals(tableName)) {
return true;
} else if (ignoreCase && trigger.getSourceTableName().equalsIgnoreCase(tableName)) {
return true;
}
}
return false;
Expand Down Expand Up @@ -985,7 +990,7 @@ protected void updateOrCreateDatabaseTriggers(List<Trigger> triggers, StringBuil

} else {
log.error(
"The configured table does not exist in the datasource that is configured: {}",
"Could not find any database tables matching '{}' in the datasource that is configured",
trigger.qualifiedSourceTableName());

if (this.triggerCreationListeners != null) {
Expand Down

0 comments on commit 231af95

Please sign in to comment.