-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[MSSQL] Can't insert when there is a trigger on the table #5009
Comments
Any news about that? Anyone found a solution? I manage to make it work but i'm not proud of myself, i just hope we have a solution soon |
@AntonioBusillo |
@RMTTyszka would you mind sharing your workaround? |
I'm facing the same problem. We mostly managed it by using a struct without the primary key defined, this stops gorm adding the OUTPUT clause. Of course this also stops gorm retrieving the inserted ID, so we have to perform a SELECT after the INSERT when we need the ID. Has anyone better ideas? |
Hi, I have the same issue :(
|
See also here. |
Your Question
I'm trying to insert some values using the Create functions but, since there's an indication about the Primary Key, it automatically adds "OUTPUT INSERTED.ID" into the INSERT INTO returning an error since the table has a trigger. [FIRST CASE]
BUT
If I remove the primary key, it returns "6 rows affected" even if it adds only one row. [SECOND CASE]
I'm using gorm v1.22.5 and dialect gorm.io/driver/sqlserver v1.2.1
The document you expected this should be explained
First Case:
Second Case:
Expected answer
Why does it show 6 rows affected?
Is there a way to have the ID of the inserted value without using the OUTPUT clause?
The text was updated successfully, but these errors were encountered: