0

I'm getting an error on a query in PostgreSQL in a rake task I'm trying to et up.

  posts = Post.where("status IS ? AND publish_on < ?", 'queued', Time.now)

Here's the error:

PGError: ERROR:  syntax error at or near "'queued'"
    LINE 1: SELECT "posts".* FROM "posts"  WHERE (status IS 'queued' AND...
                                                            ^
    : SELECT "posts".* FROM "posts"  WHERE (status IS 'queued' AND publish_on < '2012-04-29 23:44:06.423516')

At first I thought it was the quotes, but changing them didn't work. Now I think it's probaly how I'm contstructing the and clause?

1 Answer 1

2

IS is only for comparing against TRUE, FALSE, or NULL. You probably want = instead:

posts = Post.where("status = ? AND publish_on < ?", 'queued', Time.now)
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.