-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause. #27
Comments
I am facing the same issue. Do you guys have any update on it? |
any update for this issue? |
I've just come back from a month's holiday and things are a bit less hectic now than they were for the first half of the year so I'm going to try to dedicate at least a few hours a week to updating this library. I'll prioritise merging PRs, since my personal Elixir skills are rather rusty at this point, but if nobody else is picking this issue up I'll get to it. |
I just ran into this issue as well. I'd be glad to try my hand at patching this if someone could provide some pointers on where to start in this codebase. This seems related: |
It looks like making inserted an optional parameter is one possible solution: https://github.com/findmypast-oss/mssql_ecto/blob/master/lib/mssql_ecto/query.ex#L107 Unfortunately, we won't be able to get the inserted data back with this approach. |
Another alternative might be to check if a trigger exists on a table and dynamically add/remove the inserted bit: https://wateroxconsulting.com/archives/find-triggers-sql-server-database/ But perhaps this would add too much overhead? |
Does setting |
I think you're right (allow the user to turn off Setting |
I meant |
In the db you can delete the trigger which is not in use. can solve this issue. I did delete the trigger from the table . and it worked fine. |
Problem:
When a database table has a trigger attached to it,
insert/1
will fail because the adapter is not utilizing anINTO
clause.This blog post from the SQL Server team explains the issue well: https://blogs.msdn.microsoft.com/sqlprogrammability/2008/07/11/update-with-output-clause-triggers-and-sqlmoreresults/
Error Example:
result:
DB Trigger Example:
Temporary Workaround:
Even if you're only looking to insert one record, you can use
insert_all/2
and pass in your one entry because it does not rely on a return value from the database.https://hexdocs.pm/ecto/Ecto.Repo.html#c:insert_all/3
Environment:
The text was updated successfully, but these errors were encountered: