I have a Rails 3.1 setup with postgres 8.4. Here are my gem versions:
activerecord (3.1.3) activemodel (= 3.1.3) activesupport (= 3.1.3) arel (~> 2.2.1) tzinfo (~> 0.3.29) activerecord-jdbc-adapter (1.2.1) activerecord-jdbcpostgresql-adapter (1.2.1) activerecord-jdbc-adapter (~> 1.2.1) jdbc-postgres (~> 9.0.0)
Now, when I do this query in my controller:
@topics = Topic.find(:all, :conditions => ["\"ForumID\" in ?, @forum_ids]
I get this error:
ActiveRecord::JDBCError: ERROR: syntax error at or near "'abc123'"
Position: 62: SELECT "topic".* FROM "topic" WHERE ("ForumID" in 'abc123','1234')
Completed 500 Internal Server Error in 314ms
ActiveRecord::StatementInvalid (ActiveRecord::JDBCError: ERROR: syntax error at or near "'abc123'"
Position: 62: SELECT "topic".* FROM "topic" WHERE ("ForumID" in 'abc123','1234')):
I think the problem is where the parenthesis is being placed in the SQL statement. It should be after in instead of being before "ForumID".
SELECT "topic".* FROM "topic" WHERE "ForumID" in ('abc123','1234') works perfectly, so is this a bug in the postgresql adapter, or am I doing something wrong in my query?
Thanks.