Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed wrong quoting of index names in postgres [#2402 state:resolved]

Signed-off-by: Tarmo Tänav <tarmo@itech.ee>
  • Loading branch information...
commit de4cc53f7428090600b9e31ee39cf8c4c0df811e 1 parent 6060123
@maxlapshin maxlapshin authored lifo committed
View
2  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -858,7 +858,7 @@ def rename_column(table_name, column_name, new_column_name)
# Drops an index from a table.
def remove_index(table_name, options = {})
- execute "DROP INDEX #{index_name(table_name, options)}"
+ execute "DROP INDEX #{quote_table_name(index_name(table_name, options))}"
end
# Maps logical Rails types to PostgreSQL-specific data types.
View
10 activerecord/test/cases/schema_test_postgresql.rb
@@ -113,6 +113,16 @@ def test_dump_indexes_for_schema_two
do_dump_index_tests_for_schema(SCHEMA2_NAME, INDEX_A_COLUMN, INDEX_B_COLUMN_S2)
end
+ def test_with_uppercase_index_name
+ ActiveRecord::Base.connection.execute "CREATE INDEX \"things_Index\" ON #{SCHEMA_NAME}.things (name)"
+ assert_nothing_raised { ActiveRecord::Base.connection.remove_index :things, :name => "#{SCHEMA_NAME}.things_Index"}
+
+ ActiveRecord::Base.connection.execute "CREATE INDEX \"things_Index\" ON #{SCHEMA_NAME}.things (name)"
+ ActiveRecord::Base.connection.schema_search_path = SCHEMA_NAME
+ assert_nothing_raised { ActiveRecord::Base.connection.remove_index :things, :name => "things_Index"}
+ ActiveRecord::Base.connection.schema_search_path = "public"
+ end
+
private
def columns(table_name)
@connection.send(:column_definitions, table_name).map do |name, type, default|
Please sign in to comment.
Something went wrong with that request. Please try again.