aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-07-23 15:06:21 -0700
committerStan Hu <stanhu@gmail.com>2019-07-24 20:21:35 -0700
commitec0dc76c06a0b7afadab7ca5629a8d6a2f3d6370 (patch)
tree12e543cffe1cc26968d6263e8b32b95d3ca9aa9c /activerecord/lib
parentd3327ca40eaea734b2302c7a9ffa0360033a7484 (diff)
downloadrails-ec0dc76c06a0b7afadab7ca5629a8d6a2f3d6370.tar.gz
rails-ec0dc76c06a0b7afadab7ca5629a8d6a2f3d6370.tar.bz2
rails-ec0dc76c06a0b7afadab7ca5629a8d6a2f3d6370.zip
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
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb2
1 files changed, 1 insertions, 1 deletions
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]