> uninsured_codes = nil
=> nil
> DB[:insurances].filter(:code => uninsured_codes).sql
=> "SELECT * FROM `insurances` WHERE (`code` IS NULL)"
Good!
> uninsured_codes = ['', 'NO INS', 'NO INS HS', 'HMLS-NOIN', 'NDA']
=> ["", "NO INS", "NO INS HS", "HMLS-NOIN", "NDA"]
> DB[:insurances].filter(:code => uninsured_codes).sql
=> "SELECT * FROM `insurances` WHERE (`code` IN ('', 'NO INS', 'NO INS
HS', 'HMLS-NOIN', 'NDA'))"
Good!
> uninsured_codes = [nil, '', 'NO INS', 'NO INS HS', 'HMLS-NOIN', 'NDA']
=> [nil, "", "NO INS", "NO INS HS", "HMLS-NOIN", "NDA"]
> DB[:insurances].filter(:code => uninsured_codes).sql
=> "SELECT * FROM `insurances` WHERE (`code` IN (NULL, '', 'NO INS',
'NO INS HS', 'HMLS-NOIN', 'NDA'))"
Above doesn't work in mysql. The record with NULL is not returned.
Need to see:
=> "SELECT * FROM `insurances` WHERE ((`code` IN ('', 'NO INS', 'NO
INS HS', 'HMLS-NOIN', 'NDA')) OR (`code` IS NULL))"
With the above query, the NULL record is returned along with the others.
Can Sequel be extended to do "OR <field> IS NULL" when an array with
legit values as well as nil is passed?
Michael
--
http://codeconnoisseur.org
--
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.