From ec0dc76c06a0b7afadab7ca5629a8d6a2f3d6370 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 23 Jul 2019 15:06:21 -0700 Subject: Fix index_exists? for PostgreSQL expression indexes Previously Rails expected indexes to be an array of columns, but for PostgreSQL a expression index can just be a string of text. Handle this by forcing `Index#columns` to be an Array inside `index_exists?`. Closes #36739 --- .../lib/active_record/connection_adapters/abstract/schema_statements.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/connection_adapters') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 13f94a4722..88367c79a1 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -100,7 +100,7 @@ module ActiveRecord def index_exists?(table_name, column_name, options = {}) column_names = Array(column_name).map(&:to_s) checks = [] - checks << lambda { |i| i.columns == column_names } + checks << lambda { |i| Array(i.columns) == column_names } checks << lambda { |i| i.unique } if options[:unique] checks << lambda { |i| i.name == options[:name].to_s } if options[:name] -- cgit v1.2.3