Ahh, ok, I see. I had assumed that first() and similar were like Java
executors, finally grabbing the row(s).

This has answered a lot, I'm very appreciative!

On Sun, Jan 10, 2010 at 8:01 PM, Jeremy Evans <[email protected]>wrote:

> On Jan 10, 3:11 pm, ThinkWriteMute <[email protected]> wrote:
> > Ah that makes perfect sense. So here's what I did:
> >
> > $accounts.where(:name => account_name).first.update(:current_login =>
> > @user)
> >
> > But it doesn't change?
>
> Dataset#first returns a hash, so you are still calling Hash#update.
>
> > Does that mean .update requires a whole hash to replace the previous
> > one? I didn't think that's how it worked.
>
> Hash#update is unrelated to Sequel. Allow me to go into more detail.
> For updates of single records, models are often used.  Dataset
> instances operate on sets of rows, while model instances operate on
> single rows.  You are trying to update a single row with a dataset,
> which is why you are having issues.  With datasets, you have to do
> something like:
>
>  a = $accounts.where(:name => account_name).first
>  $accounts.where(:id=>a[:id]).update(:current_login =>@user)
>
> Or, assuming that name is unique, just a single update query:
>
>  $accounts.where(:name => account_name).update(:current_login =>
> @user)
>
> With models, you could do:
>
>  Account[:name=>account_name].update(:current_login =>@user)
>
> Model.[] returns a model object, and Model#update updates the database
> with the changed columns.
>
> 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]<sequel-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/sequel-talk?hl=en.
>
>
>
>


-- 
Kurtis Rainbolt-Greene
1-541-805-2263
http://krainbolt-greene.selfip.net
--
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