Replies: 4 comments 3 replies
-
|
We are using sequel 5.77.0 |
Beta Was this translation helpful? Give feedback.
-
|
The error you are getting is a database error, not a Sequel::Model error. |
Beta Was this translation helpful? Give feedback.
-
|
FWIW, |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the quick replies, I misunderstood this mechanism. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Given a model
class Status < Sequel::Model(DB[:statuses])
end
It has only two columns id and name.
When i try to run
::Statuses.unrestrict_primary_key::Statuses.find_or_create(id: 1, name: 'Active')::Statuses.unrestrict_primary_keyI get the error "Cannot insert explicit value for identity column in table 'statuses' when IDENTITY_INSERT is set to OFF."
Only I got it to work was
::Statuses.unrestrict_primary_key::Statuses.db.run "SET IDENTITY_INSERT statuses ON"::Statuses.find_or_create(id: 1, name: 'Active')::Statuses.db.run "SET IDENTITY_INSERT statuses OFF"::Statuses.unrestrict_primary_keyAm I missing something or should the unrestrict_primary_key method enable and disable identity insert?
Beta Was this translation helpful? Give feedback.
All reactions