Use the schema_search_path in prepared statements.

To allow the use of prepared statements when changing schemas in
postgres, the schema search path is added to the sql key.
This commit is contained in:
Juan M. Cuello
2011-10-05 11:43:03 -03:00
parent c495bfc127
commit cfc95d89ae

View File

@@ -1035,13 +1035,14 @@ module ActiveRecord
end
def exec_cache(sql, binds)
unless @statements.key? sql
sql_key = "#{schema_search_path}-#{sql}"
unless @statements.key? sql_key
nextkey = @statements.next_key
@connection.prepare nextkey, sql
@statements[sql] = nextkey
@statements[sql_key] = nextkey
end
key = @statements[sql]
key = @statements[sql_key]
# Clear the queue
@connection.get_last_result