aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorJuan M. Cuello <juanmacuello@gmail.com>2011-10-05 11:43:03 -0300
committerJuan M. Cuello <juanmacuello@gmail.com>2011-10-05 11:43:03 -0300
commitcfc95d89aeffba5a026afcf272bdf3ff231a8983 (patch)
tree9fda5022feb523e0479cc8a0dcc8fabccbc66043 /activerecord/lib/active_record
parentc495bfc127405f7ead0d1c275c4d75682a51e00e (diff)
downloadrails-cfc95d89aeffba5a026afcf272bdf3ff231a8983.tar.gz
rails-cfc95d89aeffba5a026afcf272bdf3ff231a8983.tar.bz2
rails-cfc95d89aeffba5a026afcf272bdf3ff231a8983.zip
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.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 5402918b1d..d859843260 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -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