On Jun 30, 12:28 pm, Jim Morris <[EMAIL PROTECTED]> wrote:
> Hmm that looks cleaner but gives me an error...
>
> I left out the indexing for simplicity...
>
> v= 123
> periods= [:day, :week, :month, :year, :alltime]
> DB[:stats].update_sql(periods.inject({}){|h, p| h[p] = p + v})
>
> => NoMethodError: undefined method `[]=' for
> #<Sequel::SQL::NumericExpression:0xb7b289c0>

I forgot to have the block return the new hash:

  ds.update_sql(periods.inject({}){|h, p| h[p|idx] = (p|idx) + v; h})

I tend to avoid using inject in such a case anyway, as I find the
following easier to read:

  h = {}
  periods.each{|p| h[p|idx] = (p|idx) + v}
  ds.update_sql(h)

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