Rails 3.2/4 force prepared statements to be used

sl_bug
Tue, 02 Oct 2012 12:36:18 -0000

I''ve already asked about this on StackOverflow with no luck on answer -
http://stackoverflow.com/questions/12617237/rails-3-2-force-prepared-statements/12617681

Simplified Case:

Hotel.find(1) - use prepared statement
# SELECT "hotels".* FROM "hotels" WHERE
"hotels"."id" = $1 LIMIT 1 [["id",
1]]

Hotel.where(id: 1) - without prepared statement
# SELECT "hotels".* FROM "hotels" WHERE
"hotels"."id" = 1

Hotel.where(Hotel.arel_table[:id].eq(1)) - without prepared statement
# SELECT "hotels".* FROM "hotels" WHERE
"hotels"."id" = 1

Hotel.where(''id = :id'', id: 1) - without prepared statement
# SELECT "hotels".* FROM "hotels" WHERE (id = 1)

How to force rails to use prepared statements? May be not in all cases, but
at least with arel_table.

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/ACgdfArFpZsJ.
For more options, visit https://groups.google.com/groups/opt_out.