On Thursday, March 7, 2019 at 3:54:46 AM UTC-8, Quackerjack wrote: > > Hi Jeremy, > > i ran in following situation on a MS SQL Database (tiny_tds adapter used): > > irb(main):036:0> DB_OVS[:xxx].where(ausleuchtung_vorhanden: nil).count > => 61 > irb(main):038:0> DB_OVS[:xxx].where(ausleuchtung_vorhanden: "nein").count > => 17 > irb(main):037:0> DB_OVS[:xxx].where(ausleuchtung_vorhanden: [nil, "nein" > ]).count > => 17 > irb(main):039:0> DB_OVS[:xxx].where(ausleuchtung_vorhanden: [nil, "nein" > ]).sql > => "SELECT * FROM [xxx].[xxx] WHERE ([AUSLEUCHTUNG_VORHANDEN] IN (NULL, > N'nein'))" > > > I suggest that MS SQL DB cant handle the IN clause with NULL values and > real values but im not a expert. I fixed it by using: > > DB_OVS[:xxx].where(ausleuchtung_vorhanden: nil).or(ausleuchtung_vorhanden: > ["nein"]).count > irb(main):044:0> DB_OVS[:xxx].where(ausleuchtung_vorhanden: nil).or( > ausleuchtung_vorhanden: ["nein"]).sql > => "SELECT * FROM [xxx].[xxx] WHERE (([AUSLEUCHTUNG_VORHANDEN] IS NULL) > OR ([AUSLEUCHTUNG_VORHANDEN] IN (N'nein')))" > > > But i would love to use Array that can contain Nil, so that i dont have to > split the searched values in Nil and other values. >
You can use the split_array_nil extension: http://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/split_array_nil_rb.html Thanks, Jeremy -- 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 post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
