Skip to content

Commit

Permalink
SYMMETRICDS-615 - When a timestamp with time zone column is part of a…
Browse files Browse the repository at this point in the history
… primary key or part of a table w.out a primary key, then the trigger fails to create.
  • Loading branch information
chenson42 committed May 1, 2012
1 parent 2842882 commit 1f30534
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
Expand Up @@ -2,8 +2,15 @@

import java.util.HashMap;

import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.symmetric.db.AbstractTriggerTemplate;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.io.data.DataEventType;
import org.jumpmind.symmetric.model.Channel;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.jumpmind.util.FormatUtils;

public class MsSqlTriggerTemplate extends AbstractTriggerTemplate {

Expand Down Expand Up @@ -155,6 +162,19 @@ public MsSqlTriggerTemplate(ISymmetricDialect symmetricDialect) {

}

@Override
public String replaceTemplateVariables(DataEventType dml, Trigger trigger,
TriggerHistory history, Channel channel, String tablePrefix, Table table,
String defaultCatalog, String defaultSchema, String ddl) {
ddl = super.replaceTemplateVariables(dml, trigger, history, channel, tablePrefix, table,
defaultCatalog, defaultSchema, ddl);
Column[] columns = table.getPrimaryKeyColumns();
ddl = FormatUtils.replace("declareOldKeyVariables",
buildKeyVariablesDeclare(columns, "old"), ddl);
ddl = FormatUtils.replace("declareNewKeyVariables",
buildKeyVariablesDeclare(columns, "new"), ddl);
return ddl;
}

@Override
protected boolean requiresEmptyLobTemplateForDeletes() {
Expand Down
Expand Up @@ -2,8 +2,15 @@

import java.util.HashMap;

import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.symmetric.db.AbstractTriggerTemplate;
import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.io.data.DataEventType;
import org.jumpmind.symmetric.model.Channel;
import org.jumpmind.symmetric.model.Trigger;
import org.jumpmind.symmetric.model.TriggerHistory;
import org.jumpmind.util.FormatUtils;

public class SybaseTriggerTemplate extends AbstractTriggerTemplate {

Expand Down Expand Up @@ -135,5 +142,19 @@ public SybaseTriggerTemplate(ISymmetricDialect symmetricDialect) {
sqlTemplates.put("initialLoadSqlTemplate" ,
"select $(columns) from $(schemaName)$(tableName) t where $(whereClause) " );
}

@Override
public String replaceTemplateVariables(DataEventType dml, Trigger trigger,
TriggerHistory history, Channel channel, String tablePrefix, Table table,
String defaultCatalog, String defaultSchema, String ddl) {
ddl = super.replaceTemplateVariables(dml, trigger, history, channel, tablePrefix, table,
defaultCatalog, defaultSchema, ddl);
Column[] columns = table.getPrimaryKeyColumns();
ddl = FormatUtils.replace("declareOldKeyVariables",
buildKeyVariablesDeclare(columns, "old"), ddl);
ddl = FormatUtils.replace("declareNewKeyVariables",
buildKeyVariablesDeclare(columns, "new"), ddl);
return ddl;
}

}
Expand Up @@ -361,12 +361,7 @@ public String replaceTemplateVariables(DataEventType dml, Trigger trigger,
getPrimaryKeyWhereString(dml == DataEventType.DELETE ? oldTriggerValue
: newTriggerValue, table.hasPrimaryKey() ? table.getPrimaryKeyColumns()
: table.getColumns()), ddl);

ddl = FormatUtils.replace("declareOldKeyVariables",
buildKeyVariablesDeclare(columns, "old"), ddl);
ddl = FormatUtils.replace("declareNewKeyVariables",
buildKeyVariablesDeclare(columns, "new"), ddl);


String builtString = buildColumnNameString(oldTriggerValue, columns);
ddl = FormatUtils.replace("oldKeyNames", StringUtils.isNotBlank(builtString) ? ","
+ builtString : "", ddl);
Expand Down

0 comments on commit 1f30534

Please sign in to comment.