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.

2
  • 1
    consider using the same database for both development and production, there is no reason not to really Commented Oct 15, 2013 at 15:46
  • 1
    Has ActiveRecord fixed its boolean brain damage with SQLite? 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. Commented Oct 15, 2013 at 16:06

1 Answer 1

2

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.