binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.4k stars 133 forks source link

does_not_equal function does not work for nil #135

Open ghazel opened 13 years ago

ghazel commented 13 years ago

The _equals function works for strings and nil, but the _does_not_equal function does not.

User.name_equals(x)

Submits either:

SELECT * FROM `users` WHERE (users.name = 'foo')

or:

SELECT * FROM `users` WHERE (users.name IS NULL)

Depending on whether x is "foo" or nil. This is correct. However this:

User.name_does_not_equal(x)

Submits either:

SELECT * FROM `users` WHERE (users.name != 'foo')

or:

SELECT * FROM `users` WHERE (users.name != NULL)

The later of which is incorrect. It should be users.name IS NOT NULL.