On Mar 12, 10:07 am, Matt Jones <[email protected]> wrote:
> SELECT * FROM some_models WHERE boolean_field = TRUE
This doesn't actually work across both SQLite3 and PostgreSQL. The
only portable solution I found was:
SELECT * FROM model WHERE (boolean_field)
In other words, trying to test IS, IS NOT, or = all failed horribly on
one platform or the other, but simply testing for the field itself
returned the proper equality test. I'm not sure why they failed, mind
you, just that empirically there's something fundamentally wrong with
the way the equality is being tested across the supported platforms.
In the end, I ended up with the following named scope in my model:
scope :past_due,
where('(requested_start_date < ?) AND NOT complete',
Date.today).
order('requested_start_date ASC')
Whether this is a bug, or simply an ugly edge case, I will leave up to
those wiser than myself.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: 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/rubyonrails-talk?hl=en.