The following scope works on sqlite3 in development, but fails in
production on PostgreSQL:

  scope :past_due,
        where('requested_start_date < ? AND complete IS NOT ?',
Date.today, true).
        order('requested_start_date ASC')

2011-03-11T15:51:33-08:00 app[web.1]: ActiveRecord::StatementInvalid
(PGError: ERROR:  syntax error at or near "'t'"
2011-03-11T15:51:33-08:00 app[web.1]: LINE 1: ...requested_start_date
< '2011-03-11' AND complete IS NOT 't')

Contrariwise, sqlite3 blows up if you use a construct like:
  scope :past_due,
        where('requested_start_date < ? AND complete IS NOT TRUE',
Date.today).
        order('requested_start_date ASC')

I'm currently testing now for "t":

  scope :past_due,
        where('requested_start_date < ? AND complete IS NOT "t"',
Date.today).
        order('requested_start_date ASC')

but this seems wrong somehow. What is the correct way to test for a
Boolean value in a named scope that will be portable across all
databases?

-- 
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.

Reply via email to