Skip to content

Commit

Permalink
Fixed wrong quoting of index names in postgres [#2402 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Tarmo Tänav <tarmo@itech.ee>
  • Loading branch information
maxlapshin authored and lifo committed Apr 21, 2009
1 parent 6060123 commit de4cc53
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -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.
Expand Down
10 changes: 10 additions & 0 deletions activerecord/test/cases/schema_test_postgresql.rb
Expand Up @@ -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|
Expand Down

0 comments on commit de4cc53

Please sign in to comment.