我正在尝试使用rake任务在PostgreSQL中查询错误。
posts = Post.where("status IS ? AND publish_on < ?", 'queued', Time.now)
这是错误:
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')
起初我认为这是引用,但改变它们并不起作用。现在我认为我是如何同意和条款的?
答案 0 :(得分:2)
IS
仅用于与TRUE
,FALSE
或NULL
进行比较。您可能需要=
代替:
posts = Post.where("status = ? AND publish_on < ?", 'queued', Time.now)