einzige / sneaky-save

Allows to update complex objects without triggering validations or callbacks.
46 stars 30 forks source link

sneaky_update attempts to update primary column #10

Open sys-64738 opened 9 years ago

sys-64738 commented 9 years ago

I'm getting an error from my SQL Server database ("Cannot update identity column 'id'") when running "sneaky_save!" for updating an existing record because the SQL UPDATE statement also sets the "id" column (though it was actually not changed).

I see that "sneaky_create" has some code for handling primary key columns, but sneaky_update hasn't.

Shouldn't it actually just update only the columns from "changed_attributes", rather then all attributes? And then also reset changed_attributes to an empty hash afterwards?

einzige commented 9 years ago

thanks @sys-64738 , i will take a look today

einzige commented 9 years ago

@sys-64738 can you please provide the version of ActiveRecord you use, your gemfile, I am trying to reproduce.

sys-64738 commented 9 years ago

Thank you for looking into it. I have activerecord (3.2.22) and activerecord-sqlserver-adapter (3.2.13).