On Apr 28, 1:13 pm, bizzz <[email protected]> wrote:
> Hello,
> i've stumbled upon something that must have a simplest explanation but
> i can't find it.
> I just want to update a field in my MySQL DB:
> def set_done(id)
>   DB[:tmp][:id =>id].update(:done => 1)
> end
> it works without errors, returns hash of DB entry, but DB doesn't
> change :(
> So i try DB["update tmp set done = 1 where id = ?", id]
> it returns Sequel::MySQL::Dataset object, but result is the same.
> I tried that query manually, it works.
> This puzzle is driving me crazy, please help me solve it.

You are calling Hash#update, which has no effect on the database.  If
that is the query you want:

  DB[:tmp].filter(:id=>id).update(:done=>1)

That calls Dataset#update instead of Hash#update as Dataset#filter
returns a dataset, as opposed to Dataset#[] which returns a hash.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to