Oops, that last was sent a little too soon. I had wanted to show the
alternative way of building the ORs:

On Nov 9, 9:28 am, Phrogz <[email protected]> wrote:
> irb(main):001:0> require 'sequel'; DB = Sequel.sqlite
> => #<Sequel::SQLite::Database: "sqlite:/">
>
> irb(main):002:0> selected = DB[:USER].select(:ID, :NAME, :CITY)
> => #<Sequel::SQLite::Dataset: "SELECT `ID`, `NAME`, `CITY` FROM
> `USER`">

irb(main):012:0> f1 = selected.filter( :lower.sql_function(:email)
=>"mail" ); nil
=> nil
irb(main):013:0> f2 = f1.or( :lower.sql_function(:name).like("i%") );
nil
=> nil
irb(main):014:0> f3 = f2.or( :lower.sql_function(:city).like("l%") );
nil
=> nil
irb(main):015:0> f3.sql
=> "SELECT `ID`, `NAME`, `CITY` FROM `USER` WHERE (((lower(`email`) =
'mail') OR (lower(`name`) LIKE 'i%')) OR (lower(`city`) LIKE 'l%'))"

Of course you can also re-use the same variable instead of creating f1/
f2/f3, like  selected = selected.or( ... )
--~--~---------~--~----~------------~-------~--~----~
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