rzane/baby_squeel

empty hash in where.has causes bad where clause

Closed this issue · 1 comments

fetep commented

Issue

When using a hash of filters from a where.has block, everything works fine unless that hash happens to be empty. In the case of an empty hash, it's adding a where 1=0 clause to the generated SQL query.

Reproduction

With squeel (working):

>> filter = {}
>> Device.where { filter }.to_sql
=> "SELECT `devices`.* FROM `devices` "

With baby_squeel (not working):

 >> filter = {}
 >> Device.where.has { filter }.to_sql
 => "SELECT `devices`.* FROM `devices` WHERE (1=0)"
rzane commented

This should be fixed in v1.1.5. It should be available now.