Permalink
Browse files

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.
  • Loading branch information...
1 parent c495bfc commit cfc95d89aeffba5a026afcf272bdf3ff231a8983 @Juanmcuello Juanmcuello committed Oct 5, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -1035,13 +1035,14 @@ def exec_no_cache(sql, binds)
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

0 comments on commit cfc95d8

Please sign in to comment.