diff options
author | Matthew Draper <matthew@trebex.net> | 2015-09-07 01:07:51 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2015-09-07 01:11:51 +0930 |
commit | f1f0a3f8d99aef8aacfa81ceac3880dcac03ca06 (patch) | |
tree | 65013af4d379038444e8827ac3a8a9660e356131 /activerecord/lib | |
parent | 096252795341518c04e1bb47a32450ade7d7e169 (diff) | |
download | rails-f1f0a3f8d99aef8aacfa81ceac3880dcac03ca06.tar.gz rails-f1f0a3f8d99aef8aacfa81ceac3880dcac03ca06.tar.bz2 rails-f1f0a3f8d99aef8aacfa81ceac3880dcac03ca06.zip |
Fix test failures from premature merge of #21317
Apparently I managed to forget how similar the "tests passing" and
"no status reported" merge indicators look.
Note that the previous `stubs` in test_add_index wasn't working:
the method was still called, and just happened to return false.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index 26ef23a0d9..69aa02ccf4 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -101,15 +101,19 @@ module ActiveRecord # Verifies existence of an index with a given name. def index_name_exists?(table_name, index_name, default) + table = Utils.extract_schema_qualified_name(table_name.to_s) + index = Utils.extract_schema_qualified_name(index_name.to_s) + select_value(<<-SQL, 'SCHEMA').to_i > 0 SELECT COUNT(*) FROM pg_class t INNER JOIN pg_index d ON t.oid = d.indrelid INNER JOIN pg_class i ON d.indexrelid = i.oid + LEFT JOIN pg_namespace n ON n.oid = i.relnamespace WHERE i.relkind = 'i' - AND i.relname = '#{index_name}' - AND t.relname = '#{table_name}' - AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname = ANY (current_schemas(false)) ) + AND i.relname = '#{index.identifier}' + AND t.relname = '#{table.identifier}' + AND n.nspname = #{index.schema ? "'#{index.schema}'" : 'ANY (current_schemas(false))'} SQL end @@ -450,7 +454,7 @@ module ActiveRecord def remove_index(table_name, options = {}) #:nodoc: index_name = index_name_for_remove(table_name, options) algorithm = - if options.key?(:algorithm) + if Hash === options && options.key?(:algorithm) index_algorithms.fetch(options[:algorithm]) do raise ArgumentError.new("Algorithm must be one of the following: #{index_algorithms.keys.map(&:inspect).join(', ')}") end |