Rails 3.2/4 force prepared statements to be used

I’ve already asked about this on StackOverflow with no luck on answer -

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs