On Mar 11, 7:43 pm, "Todd A. Jacobs" <[email protected]> wrote: > On Mar 11, 4:31 pm, "Todd A. Jacobs" <[email protected]> > wrote: > > > So, after more trial and error, this is the portable version. > > > scope :past_due, > > where('(requested_start_date < ?) AND (complete = ?)', > > Date.today, true). > > order('requested_start_date ASC') > > > I'd still like to understand *why* this is more portable, though, if > > anybody knows the answer. > > Turns out this still isn't portable. On PostgreSQL I have to run: > > Job.where('(requested_start_date < ?) AND (complete IS NOT TRUE)', > Date.today) > > but this is still blowing up SQLite3. Sadness. Back to the drawing > board; any suggestions?
What type is 'complete' declared as? From this list, it looks like PG supports a real boolean type: http://troels.arvin.dk/db/rdbms/#data_types-boolean Looking at the ActiveRecord source, it looks like doing this: SomeModel.find(:conditions => ['boolean_field = ?', true]) will get the SQL: SELECT * FROM some_models WHERE boolean_field = 't' which is pretty wrong. The behavior is inherited from other DBs that don't have a real boolean type (MySQL, for instance, aliases TINYINT(1) to BOOLEAN, SQLite tends to store 't' and 'f', and SQL Server devotees store 0xFF and 0x00). Perhaps the Postgres adapter should override quoted_true and quoted_false (in quoting.rb) to return a more appropriate value for boolean columns? I'm guessing that this SQL would work: SELECT * FROM some_models WHERE boolean_field = TRUE --Matt Jones -- 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.

