Ruby on Rails
Thursday, October 1, 2015
Activerecord generates parameterized queries for basic types, but, it does parameterize array types.
E.g.
Article.where(id: 1) # generates # SELECT "articles".* FROM "articles" WHERE "articles"."id" = $1 [["id", 1]]
But,
Article.where(id: [1,2]) # generates # SELECT "articles".* FROM "articles" WHERE "articles"."id" IN (1, 2) # rather than # SELECT "articles".* FROM "articles" WHERE "articles"."id" IN ($1, $2) [["id", 1], ["id", 2],]
Is it possible to restructure the query or use Arel to generate parameterized query for IN clauses?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3edc1ebe-8d1b-4b42-9229-75934110b26b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment