From: khaines@... Date: 2006-12-06T10:18:54+09:00 Subject: Re: Lisp comprehensions => SQL On Wed, 6 Dec 2006, Victor "Zverok" Shepelev wrote: > #having > employees.select do |e| > sort_by(e.age) > limit(2,10) > (e.name == 'John') & (e.salary > 50) > end > > #proposal: > > employees.select{|e| (e.name == 'John') & (e.salary > 50)}.sort_by{|e| > e.age}[2..10] > > The latter is "just Ruby". > Actually, you could do that second one with Kansas. With the current Kansas, it'd be: dbh.select(:Employees) {|e| (e.name == 'John') & (e.salary > 50)}.sort_by{|e| e.age}[2..10] The difference, though, is that it won't do all of that on the database. The database will do "select * from employees where e.name = 'John' and e.salary > 50" and then the results will be sorted by Ruby and the set extracted by Ruby. Kirk Haines