Alexander Grebennik
2012-Oct-02 07:53 UTC
Rails 3.2/4 force prepared statements to be used
I''ve already asked this on StackOverflow with no luck on answer - http://stackoverflow.com/questions/12617237/rails-3-2-force-prepared-statements Simplified case: Hotel.find(1) - executes using prepared statement SELECT "hotels".* FROM "hotels" WHERE "hotels"."id" = $1 LIMIT 1 [["id", 1]] Hotel.where(id: 1) - no prepared statement SELECT "hotels".* FROM "hotels" WHERE "hotels"."id" = 1 t = Hotel.arel_table; Hotel.where(t[:id].eq(1)) - no prepared statement SELECT "hotels".* FROM "hotels" WHERE "hotels"."id" = 1 Hotel.where(''id = :id'', id: 1) - no prepared statement SELECT "hotels".* FROM "hotels" WHERE (id = 1) So question, 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: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/adpPjxCVSY0J. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
This is a mailing list for discussion about development of the rails framework itself. For questions about using rails, please post to https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-talk -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.