Skip to content

Commit

Permalink
0004826: Raima DDL Reader fails to read triggers for specific table
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Marzullo committed Dec 3, 2021
1 parent 28583e2 commit 6f4beba
Showing 1 changed file with 17 additions and 21 deletions.
Expand Up @@ -19,21 +19,17 @@
package org.jumpmind.db.platform.raima;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.ForeignKey;
import org.jumpmind.db.model.IIndex;
import org.jumpmind.db.model.IndexColumn;
import org.jumpmind.db.model.Reference;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.model.Trigger;
import org.jumpmind.db.model.Trigger.TriggerType;
Expand Down Expand Up @@ -115,38 +111,38 @@ protected boolean isInternalForeignKeyIndex(Connection connection,

public List<Trigger> getTriggers(final String catalog, final String schema,
final String tableName) {

// TODO This change is for issue 4826, not 4824
List<Trigger> triggers = new ArrayList<Trigger>();

log.debug("Reading triggers for: " + tableName);
JdbcSqlTemplate sqlTemplate = (JdbcSqlTemplate) platform
.getSqlTemplate();

String sql = "SELECT "
+ "TRIGGERNAME, "
+ "SCHEMA, "
+ "TRIGGER_TYPE, "
+ "TABLENAME, "
+ "TRIG.* "
+ "FROM SYSTEM.TRIGGERS AS TRIG "
+ "WHERE TABLENAME=? and SCHEMA=? ;";
+ "schemaname, "
+ "tabname, "
+ "name, "
+ "event, "
+ "trig.* "
+ "FROM sys_trigger trig "
+ "WHERE tabname = ? AND schemaname = ?";
triggers = sqlTemplate.query(sql, new ISqlRowMapper<Trigger>() {
public Trigger mapRow(Row row) {
Trigger trigger = new Trigger();
trigger.setName(row.getString("TRIGGERNAME"));
trigger.setSchemaName(row.getString("SCHEMA"));
trigger.setTableName(row.getString("TABLENAME"));
trigger.setName(row.getString("NAME"));
trigger.setSchemaName(row.getString("SCHEMANAME"));
trigger.setTableName(row.getString("TABNAME"));
trigger.setEnabled(true);
String triggerType = row.getString("TRIGGER_TYPE");
if (triggerType.equals("DELETE")
|| triggerType.equals("INSERT")
|| triggerType.equals("UPDATE")) {
trigger.setTriggerType(TriggerType.valueOf(triggerType));
String triggerType = row.getString("EVENT");
if (triggerType.equalsIgnoreCase("DELETE")
|| triggerType.equalsIgnoreCase("INSERT")
|| triggerType.equalsIgnoreCase("UPDATE")) {
trigger.setTriggerType(TriggerType.valueOf(triggerType.toUpperCase()));
}
trigger.setMetaData(row);
return trigger;
}
}, tableName, catalog);
}, tableName, schema);

return triggers;
}
Expand Down

0 comments on commit 6f4beba

Please sign in to comment.