Re: Removing Parse-tree: Should we 'Cry' ?

2008-06-30 Thread Jeremy Evans
On Jun 29, 2:48 pm, Jim Morris [EMAIL PROTECTED] wrote: Yep just discovered that empirically, may be nice to add that to the cheat sheet :) Also for the second issue this seems to work too... Instead of...       ds.update do         periods.each do |p| # create updates for all periods

Re: Removing Parse-tree: Should we 'Cry' ?

2008-06-30 Thread Jim Morris
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

Re: Removing Parse-tree: Should we 'Cry' ?

2008-06-30 Thread Jim Morris
Point taken, I've been bitten by that inject typo many times, and still make the same mistake!! Maybe I'll remove inject from my repertoire ;) On Jun 30, 1:59 pm, Jeremy Evans [EMAIL PROTECTED] wrote: On Jun 30, 12:28 pm, Jim Morris [EMAIL PROTECTED] wrote: Hmm that looks cleaner but gives

Re: Removing Parse-tree: Should we 'Cry' ?

2008-06-29 Thread Jim Morris
Ummm is there an alternative to the .update{ } syntax? which also seems to have been deprecated? If there is it is not documented. (and I use it extensively in my scripts). Thanks On Jun 17, 8:10 am, Jeremy Evans [EMAIL PROTECTED] wrote: On Jun 17, 3:40 am, Mark V [EMAIL PROTECTED] wrote:

Re: Removing Parse-tree: Should we 'Cry' ?

2008-06-29 Thread Aman Gupta
Ummm is there an alternative to the .update{ } syntax? which also seems to have been deprecated? If there is it is not documented. (and I use it extensively in my scripts). How do you use this? Using == for assignment feels weird: DB[:table].update_sql{ :a == 1 and :b == 2 } = UPDATE

Re: Removing Parse-tree: Should we 'Cry' ?

2008-06-29 Thread Jim Morris
I use it like this... DB[:table].update{ :a :a + 1 } - UPDATE table SET a = a + 1 (I never did like the syntax but it worked) and I also use it to build up updates programatically there was a thread on that

Re: Removing Parse-tree: Should we 'Cry' ?

2008-06-29 Thread Aman Gupta
DB[:table].update{ :a :a + 1 } - UPDATE table SET a = a + 1 These work: DB[:table].update_sql( :a = (:a+1) ) = UPDATE `table` SET `a` = (`a` + 1) DB[:table].update_sql( :a = 'a+1'.lit ) = UPDATE `table` SET `a` = a+1 Aman

Re: Removing Parse-tree: Should we 'Cry' ?

2008-06-29 Thread Jim Morris
Yep just discovered that empirically, may be nice to add that to the cheat sheet :) Also for the second issue this seems to work too... Instead of... ds.update do periods.each do |p| # create updates for all periods (p|idx) (p|idx) + v end end This

Removing Parse-tree: Should we 'Cry' ?

2008-06-17 Thread Mark V
Hi, Perhaps my understanding is stale/wrong. Parse-tree was removed since it used s-expressions and these aren't available in some of the newer Ruby VM's. A downside of this was losing Sequel filters. I'm not Parse-tree guru so perhaps someone can comment on whether cry could be an