Skip to content

Commit

Permalink
#127 - if triggers not there (Azure synapse), continue
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Willey committed Mar 31, 2022
1 parent 54c7b74 commit c193582
Showing 1 changed file with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,6 @@ INNER JOIN sys.tables AS parent

}

private void UseAlternativeSql()
{
Sql = @"SELECT
tr.name AS TRIGGER_NAME,
SCHEMA_NAME(parent.schema_id) AS TRIGGER_SCHEMA,
SCHEMA_NAME(parent.schema_id) AS TABLE_SCHEMA,
parent.name AS TABLE_NAME,
OBJECTPROPERTY(tr.object_id, 'ExecIsUpdateTrigger') AS IS_UPDATE,
OBJECTPROPERTY(tr.object_id, 'ExecIsDeleteTrigger') AS IS_DELETE,
OBJECTPROPERTY(tr.object_id, 'ExecIsInsertTrigger') AS IS_INSERT,
OBJECTPROPERTY(tr.object_id, 'ExecIsAfterTrigger') AS IS_AFTER,
tr.is_instead_of_trigger AS IS_INSTEADOF,
tr.is_disabled AS IS_DISABLED,
NULL as TRIGGER_BODY
FROM sys.triggers AS tr
INNER JOIN sys.tables AS parent
ON tr.parent_id = parent.object_id
WHERE (SCHEMA_NAME(parent.schema_id) = @Owner or (@Owner is null))
AND (parent.name = @TABLE_NAME or (@TABLE_NAME is null))
";
}

protected override void AddParameters(DbCommand command)
{
AddDbParameter(command, "Owner", Owner);
Expand Down Expand Up @@ -108,9 +86,7 @@ public IList<DatabaseTrigger> Execute(IConnectionAdapter connectionAdapter)
catch (DbException dbException)
{
Trace.WriteLine(dbException);
Trace.TraceWarning("Retrying triggers without OBJECT_DEFINITION (Azure Synapse)");
UseAlternativeSql();
ExecuteDbReader(connectionAdapter);
Trace.TraceWarning("Azure Synapse does not expose trigger information");
}
return Result;
}
Expand Down

0 comments on commit c193582

Please sign in to comment.