Skip to content

Commit

Permalink
0002032: Resolve table name in create trigger statement with default …
Browse files Browse the repository at this point in the history
…catalog and schema if source catalog and schema are not specified
  • Loading branch information
chenson42 committed Oct 28, 2014
1 parent 29fe3d2 commit 8717c74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Expand Up @@ -93,7 +93,8 @@ public MsSqlTriggerTemplate(ISymmetricDialect symmetricDialect) {
" end \n" +
" $(custom_on_insert_text) \n" +
" if (@NCT = 0) set nocount off \n" +
" end " );
" end \n" +
" go");

sqlTemplates.put("updateTriggerTemplate" ,
"create trigger $(triggerName) on $(schemaName)$(tableName) with execute as "+triggerExecuteAs+" after update as \n" +
Expand Down Expand Up @@ -132,7 +133,8 @@ public MsSqlTriggerTemplate(ISymmetricDialect symmetricDialect) {
" end \n" +
" $(custom_on_update_text) \n" +
" if (@NCT = 0) set nocount off \n" +
" end " );
" end \n" +
" go");

sqlTemplates.put("updateHandleKeyUpdatesTriggerTemplate" ,
"create trigger $(triggerName) on $(schemaName)$(tableName) with execute as "+triggerExecuteAs+" after update as \n" +
Expand Down Expand Up @@ -179,7 +181,8 @@ public MsSqlTriggerTemplate(ISymmetricDialect symmetricDialect) {
" end \n" +
" $(custom_on_update_text) \n" +
" if (@NCT = 0) set nocount off \n" +
" end " );
" end \n" +
" go");

sqlTemplates.put("deleteTriggerTemplate" ,
"create trigger $(triggerName) on $(schemaName)$(tableName) with execute as "+triggerExecuteAs+" after delete as \n" +
Expand Down Expand Up @@ -210,7 +213,8 @@ public MsSqlTriggerTemplate(ISymmetricDialect symmetricDialect) {
" end \n" +
" $(custom_on_delete_text) \n" +
" if (@NCT = 0) set nocount off \n" +
" end " );
" end \n" +
" go");

sqlTemplates.put("initialLoadSqlTemplate" ,
"select $(columns) from $(schemaName)$(tableName) t where $(whereClause) " );
Expand Down
Expand Up @@ -20,6 +20,7 @@
*/
package org.jumpmind.symmetric.db;

import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isNotBlank;

import java.sql.Types;
Expand Down Expand Up @@ -247,6 +248,9 @@ protected String getSourceTablePrefix(Table table) {
+ "." : "");
String catalogPlus = (table.getCatalog() != null ? table.getCatalog() + "." : "")
+ schemaPlus;
if (isBlank(catalogPlus)) {
catalogPlus = replaceDefaultSchemaAndCatalog(catalogPlus);
}
return catalogPlus;
}

Expand All @@ -256,6 +260,9 @@ protected String getSourceTablePrefix(TriggerHistory triggerHistory) {
String catalogPlus = (triggerHistory.getSourceCatalogName() != null ? SymmetricUtils.quote(symmetricDialect, triggerHistory
.getSourceCatalogName()) + "." : "")
+ schemaPlus;
if (isBlank(catalogPlus)) {
catalogPlus = replaceDefaultSchemaAndCatalog(catalogPlus);
}
return catalogPlus;
}

Expand Down

0 comments on commit 8717c74

Please sign in to comment.