On Wednesday, August 26, 2015 at 11:05:47 AM UTC-7, James Cook wrote:
>
> I noticed today that calling update on a single record does not commit 
> changes to the database. This seems like the same odd behaviour being 
> described above.
>
> For example...
> DB[:table_name].insert(name: "Foo")
> => {id:1, name: "Foo"}
> DB[:table_name].first.update(name: "Bar")
> =>{id: 1, name: "Bar"}
> DB[:table_name].first
> =>{id:1, name:"Foo"}
>
> So, updating a record will return the record with the updated value, but 
> when reloading the record, it has reverted to it's previous state.
>
> Is this expected behaviour? If so, why?
>

Yes.  Here you are calling Hash#update, not Sequel::Model#update. 
 Hash#update only modifies the hash, it doesn't affect the database.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to