diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-20 09:06:31 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-20 09:06:31 -0800 |
commit | 92949d2a44f2c83a1537e0e4f29864ffc506cb1b (patch) | |
tree | 9d8f55487488d8961fde7d70b97ea64262c1b13c /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | |
parent | 7bae72c69f2352fd7e02f2d08adf873e4354aea0 (diff) | |
parent | 72ca2d7ff668c121d15bb247d7dcb608fc8e34c8 (diff) | |
download | rails-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.rb | 8 |
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" |