Skip to content

Commit

Permalink
0005942: SQLAnywhere DDL problems with dropping indexes and triggers,
Browse files Browse the repository at this point in the history
and trigger syntax issue for version 11 and earlier
  • Loading branch information
Philip Marzullo committed Jul 31, 2023
1 parent ebbdbbd commit 30fc2d1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Expand Up @@ -182,4 +182,8 @@ public SqlAnywhere12TriggerTemplate(ISymmetricDialect symmetricDialect) {
sqlTemplates.put("initialLoadSqlTemplate",
"select $(columns) from $(schemaName)$(tableName) t where $(whereClause) ");
}

protected String appendSemicolonAfterDeclare() {
return ";";
}
}
Expand Up @@ -26,6 +26,7 @@
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.commons.lang3.StringUtils;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.IDatabasePlatform;
import org.jumpmind.db.sql.IConnectionCallback;
Expand Down Expand Up @@ -136,10 +137,10 @@ public void dropRequiredDatabaseObjects() {
@Override
public void removeTrigger(StringBuilder sqlBuffer, final String catalogName, String schemaName,
final String triggerName, String tableName, ISqlTransaction transaction) {
final String sql = "drop trigger " + schemaName + "." + tableName + "." + triggerName;
final String sql = "drop trigger " + (StringUtils.isBlank(schemaName) ? platform.getDefaultSchema() : schemaName) + "." + tableName + "." + triggerName;
logSql(sql, sqlBuffer);
if (parameterService.is(ParameterConstants.AUTO_SYNC_TRIGGERS)) {
log.info("Dropping {} trigger for {}", triggerName, schemaName + "." + tableName + "." + triggerName);
log.info("Dropping {} trigger for {}", triggerName, (StringUtils.isBlank(schemaName) ? platform.getDefaultSchema() : schemaName) + "." + tableName + "." + triggerName);
((JdbcSqlTransaction) transaction)
.executeCallback(new IConnectionCallback<Boolean>() {
public Boolean execute(Connection con) throws SQLException {
Expand Down
Expand Up @@ -280,8 +280,12 @@ protected String buildKeyVariablesDeclare(Column[] columns, String prefix) {
throw new NotImplementedException(columns[i] + " is of type "
+ columns[i].getMappedType());
}
text += ";";
text += appendSemicolonAfterDeclare();
}
return text;
}

protected String appendSemicolonAfterDeclare() {
return "";
}
}
Expand Up @@ -193,7 +193,7 @@ protected void writeExternalForeignKeyDropStmt(Table table, ForeignKey foreignKe
@Override
public void writeExternalIndexDropStmt(Table table, IIndex index, StringBuilder ddl) {
ddl.append("DROP INDEX ");
ddl.append(getFullyQualifiedTableNameShorten(table));
ddl.append(table.getSchema()).append(".").append(table.getName());
ddl.append(".");
printIdentifier(getIndexName(index), ddl);
printEndOfStatement(ddl);
Expand Down

0 comments on commit 30fc2d1

Please sign in to comment.