-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Problems with mssql IDENTITY_INSERT #841
Comments
The issue is remarked upon in https://msdn.microsoft.com/en-nz/library/ms188059.aspx |
Hello @kiwih I think you could just Execute (sorry, I am not on a windows, so can't test it out, it would be really helpful if you could help on that) |
The problem is that you need to set it per table, not database wide, and only one table can have it at a time... Really, it needs to be set per transaction, if the transaction needs it. Does gorm know whether or not it is creating something with an ID before the transaction starts? Sent from Outlook Mobilehttps://aka.ms/blhgte |
Sound like this have to be done with overwriting callback. https://github.com/jinzhu/gorm/blob/master/callback_create.go#L117 |
Hi @kiwih I have pushed some fixes to the Let me know if still has any issues. Thank you. |
I will test it ASAP. Thanks jinzhu! |
Cool, thank you, just fyi, you need to import the mssql driver with: import _ "github.com/jinzhu/gorm/dialects/mssql" |
Hi Jinzhu, I am now setting up test environment for gorm (I have been using older commit up to this point). I will run test suite for current version against mssql and post results |
Refer to #908 in future |
With the latest version of gorm, I get the following error appearing when using mssql
Cannot insert explicit value for identity column in table 'collections' when IDENTITY_INSERT is set to OFF.
Is there any chance you could install the free MsSQL from https://www.microsoft.com/en-us/server-cloud/products/sql-server-editions/sql-server-express.aspx and try it out with your test suite?
I suspect the issue is related to #647 and #652
I will try create a small test case for you that fails during use.
The text was updated successfully, but these errors were encountered: