Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

SQL Server Update Fails with Trigger ? #375

Open
mikeloxiao opened this issue Jan 10, 2019 · 3 comments
Open

SQL Server Update Fails with Trigger ? #375

mikeloxiao opened this issue Jan 10, 2019 · 3 comments

Comments

@mikeloxiao
Copy link

If a table has a trigger in sql server, then execute update with OUTPUT will cause it to fail.

The error message is
RequestError: The target table 'tablename' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.

More information on this problem and the workaround here:
sequelize/sequelize#4807

https://stackoverflow.com/questions/13198476/cannot-use-update-with-output-clause-when-a-trigger-is-on-the-table

Does anyone have a solution?

@darrensapalo
Copy link

Back in 2016, user @mgrivera posted his workaround, which was to add the hasTrigger: true option in the model definition.

TableName = sequelize.define('TableName', { 
    <field definitions> 
}, { 
    tableName: 'TableName', 
    hasTrigger: true 
});

This workaround fixed it for me, allowing me to perform my INSERT queries. Does this work for you?

@mikeloxiao
Copy link
Author

You mean sequelize.js?

Because squel.js don't have the hasTrigger: true option.

@darrensapalo
Copy link

Yes, that is what I meant. Apologies.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants