aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-10-06 20:08:05 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-10-06 20:08:05 -0700
commit3088d23647899212f20bb8969f2084393a9e71cd (patch)
tree83c5891254dcdd0f8b9a963a345fda975c5c7f8e /activerecord/test/cases/adapters
parent99888487b63b313ea4495edd24b666fc5a3c8fe0 (diff)
parentac659b8ed3d3a12f9cce67bf0eeacb4c231c2c08 (diff)
downloadrails-3088d23647899212f20bb8969f2084393a9e71cd.tar.gz
rails-3088d23647899212f20bb8969f2084393a9e71cd.tar.bz2
rails-3088d23647899212f20bb8969f2084393a9e71cd.zip
Merge pull request #3232 from Juanmcuello/pg_prepared_statements
Use the schema_search_path in prepared statements.
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r--activerecord/test/cases/adapters/postgresql/schema_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/schema_test.rb b/activerecord/test/cases/adapters/postgresql/schema_test.rb
index 76c73e9dfa..b01eabc840 100644
--- a/activerecord/test/cases/adapters/postgresql/schema_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/schema_test.rb
@@ -38,6 +38,10 @@ class SchemaTest < ActiveRecord::TestCase
set_table_name 'test_schema."Things"'
end
+ class Thing5 < ActiveRecord::Base
+ set_table_name 'things'
+ end
+
def setup
@connection = ActiveRecord::Base.connection
@connection.execute "CREATE SCHEMA #{SCHEMA_NAME} CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})"
@@ -236,6 +240,21 @@ class SchemaTest < ActiveRecord::TestCase
end
end
+ def test_prepared_statements_with_multiple_schemas
+
+ @connection.schema_search_path = SCHEMA_NAME
+ Thing5.create(:id => 1, :name => "thing inside #{SCHEMA_NAME}", :email => "thing1@localhost", :moment => Time.now)
+
+ @connection.schema_search_path = SCHEMA2_NAME
+ Thing5.create(:id => 1, :name => "thing inside #{SCHEMA2_NAME}", :email => "thing1@localhost", :moment => Time.now)
+
+ @connection.schema_search_path = SCHEMA_NAME
+ assert_equal 1, Thing5.count
+
+ @connection.schema_search_path = SCHEMA2_NAME
+ assert_equal 1, Thing5.count
+ end
+
def test_schema_exists?
{
'public' => true,