开发者_JAVA技巧What I need is probably very simple:
Table.where('field is not true')
but I can't figure how this is done with Rails 3 query interface, and probably with meta_where. The problem is that while ":field.not_eq => nil" translates properly to "IS NOT NULL", ":field.not_eq => true" becomes "!= 1", which is clearly not the same as "IS NOT TRUE" (mysql and postgresql extension).
There are no booleans in mysql, see: http://dev.mysql.com/doc/refman/5.1/en/numeric-type-overview.html
BOOL, BOOLEAN
These types are synonyms for TINYINT(1). A value of zero is considered false. Nonzero values are considered true:
As you see booleans are always tinyints which translate into 1 or 0, this is why rails will create "field != 1" instead of field is not true.
Not sure about postgresql through.
This would be a great opportunity to make a github branch :) It's totally a feature that should be added to meta_where.
精彩评论