0

I have a ruby on rails application where I am using SQLite for development and testing, and I am using PostgreSQL in production. How can I write queries that handle booleans in my models that can handle both cases? SQLite handles booleans by using 0 and 1 , and PostgreSQL uses t and f, which is causing my problems.

GSto
  • 41,512
  • 37
  • 133
  • 184
  • 1
    consider using the same database for both development and production, there is no reason not to really – house9 Oct 15 '13 at 15:46
  • 1
    Has ActiveRecord fixed its [boolean brain damage with SQLite](http://stackoverflow.com/a/6013177/479863)? SQLite certainly thinks that booleans are C-style numbers but ActiveRecord hasn't always done so with SQLite. Anyway, stop smashing your own head with a brick and start developing on top of PostgreSQL if that's what you're deploying on, building a non-trivial database-portable application is very difficult and no ORM will protect you from the subtle differences. – mu is too short Oct 15 '13 at 16:06

1 Answers1

2

Just use true/false. ActiveRecord will handle the rest.

So for example: Post.where(published: true)

Benjamin Tan Wei Hao
  • 9,621
  • 3
  • 30
  • 56