cat test.rb
require 'sequel'
DB = Sequel.connect(adapter: 'postgres', host: 'localhost', database: 
'test1', user: 'us1', password: 'pass')

lf1 = 'f1'

puts DB[:t1].select(:f1, :f2).where{ Sequel.lit(lf1) =~ nil }.sql

puts DB[:t1].select(:f1, :f2).where{ f2 >= Sequel.lit(lf1) }.sql

puts DB[:t1].select(:f1, :f2).where{ (f3 > f1) & ((Sequel.lit(lf1) =~ nil) 
| (f2 >= f1)) }.sql

puts DB[:t1].select(:f1, :f2).where{ (f3 > f1) & ( (f2 >= f1) | 
(Sequel.lit(lf1) =~ nil) ) }.sql

ruby test.rb
SELECT "f1", "f2" FROM "t1" WHERE NULL
SELECT "f1", "f2" FROM "t1" WHERE ("f2" >= f1)
SELECT "f1", "f2" FROM "t1" WHERE (("f3" > "f1") AND true)
SELECT "f1", "f2" FROM "t1" WHERE (("f3" > "f1") AND (("f2" >= "f1") OR 
NULL))

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/f5f5bd8b-4a7c-4cbf-a52e-506e89f648d1n%40googlegroups.com.

Reply via email to