From: "Victor \"Zverok\" Shepelev" Date: 2006-12-06T17:10:10+09:00 Subject: Re: Lisp comprehensions => SQL From: khaines@enigo.com [mailto:khaines@enigo.com] Sent: Wednesday, December 06, 2006 3:19 AM >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. > This is predictable, but not very interesting. v.