Skip to content
This repository
Browse code

Merge pull request #3633 from Juanmcuello/3-1-stable

Backport #3232 to 3-1-stable
  • Loading branch information...
commit 17c84c52c14bcde0afb6a8c87cd276bf099fe350 2 parents 798a3c1 + b02daec
Jon Leighton authored
5  activerecord/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,10 @@
1 1
 ## Rails 3.1.2 (unreleased) ##
2 2
 
  3
+*   Fix problem with prepared statements and PostgreSQL when multiple schemas are used.
  4
+    *GH #3232*
  5
+
  6
+    *Juan M. Cuello*
  7
+
3 8
 *   Fix bug with PostgreSQLAdapter#indexes. When the search path has multiple schemas, spaces
4 9
     were not being stripped from the schema names after the first.
5 10
 
19  activerecord/test/cases/adapters/postgresql/schema_test.rb
@@ -37,6 +37,10 @@ class Thing4 < ActiveRecord::Base
37 37
     set_table_name 'test_schema."Things"'
38 38
   end
39 39
 
  40
+  class Thing5 < ActiveRecord::Base
  41
+    set_table_name 'things'
  42
+  end
  43
+
40 44
   def setup
41 45
     @connection = ActiveRecord::Base.connection
42 46
     @connection.execute "CREATE SCHEMA #{SCHEMA_NAME} CREATE TABLE #{TABLE_NAME} (#{COLUMNS.join(',')})"
@@ -178,6 +182,21 @@ def test_with_uppercase_index_name
178 182
     ActiveRecord::Base.connection.schema_search_path = "public"
179 183
   end
180 184
 
  185
+  def test_prepared_statements_with_multiple_schemas
  186
+
  187
+    @connection.schema_search_path = SCHEMA_NAME
  188
+    Thing5.create(:id => 1, :name => "thing inside #{SCHEMA_NAME}", :email => "thing1@localhost", :moment => Time.now)
  189
+
  190
+    @connection.schema_search_path = SCHEMA2_NAME
  191
+    Thing5.create(:id => 1, :name => "thing inside #{SCHEMA2_NAME}", :email => "thing1@localhost", :moment => Time.now)
  192
+
  193
+    @connection.schema_search_path = SCHEMA_NAME
  194
+    assert_equal 1, Thing5.count
  195
+
  196
+    @connection.schema_search_path = SCHEMA2_NAME
  197
+    assert_equal 1, Thing5.count
  198
+  end
  199
+
181 200
   private
182 201
     def columns(table_name)
183 202
       @connection.send(:column_definitions, table_name).map do |name, type, default|

0 notes on commit 17c84c5

Please sign in to comment.
Something went wrong with that request. Please try again.