aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-02-20 09:06:31 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-02-20 09:06:31 -0800
commit92949d2a44f2c83a1537e0e4f29864ffc506cb1b (patch)
tree9d8f55487488d8961fde7d70b97ea64262c1b13c /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
parent7bae72c69f2352fd7e02f2d08adf873e4354aea0 (diff)
parent72ca2d7ff668c121d15bb247d7dcb608fc8e34c8 (diff)
downloadrails-92949d2a44f2c83a1537e0e4f29864ffc506cb1b.tar.gz
rails-92949d2a44f2c83a1537e0e4f29864ffc506cb1b.tar.bz2
rails-92949d2a44f2c83a1537e0e4f29864ffc506cb1b.zip
Merge pull request #8613 from senny/8264_character_limit_for_indices
deal with long index names and internal sqlite3 operations
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb8
1 files changed, 5 insertions, 3 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 cdc8433185..2c0a18fd01 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -647,10 +647,11 @@ module ActiveRecord
index_name = index_name(table_name, column: column_names)
if Hash === options # legacy support, since this param was a string
- options.assert_valid_keys(:unique, :order, :name, :where, :length)
+ options.assert_valid_keys(:unique, :order, :name, :where, :length, :internal)
index_type = options[:unique] ? "UNIQUE" : ""
index_name = options[:name].to_s if options.key?(:name)
+ max_index_length = options.fetch(:internal, false) ? index_name_length : allowed_index_name_length
if supports_partial_index?
index_options = options[:where] ? " WHERE #{options[:where]}" : ""
@@ -665,10 +666,11 @@ module ActiveRecord
end
index_type = options
+ max_index_length = allowed_index_name_length
end
- if index_name.length > index_name_length
- raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' is too long; the limit is #{index_name_length} characters"
+ if index_name.length > max_index_length
+ raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' is too long; the limit is #{max_index_length} characters"
end
if index_name_exists?(table_name, index_name, false)
raise ArgumentError, "Index name '#{index_name}' on table '#{table_name}' already exists"