diff options
author | José Valim <jose.valim@gmail.com> | 2010-05-08 17:44:40 +0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-05-08 17:46:39 +0300 |
commit | 6626833db13a69786f9f6cd56b9f53c4017c3e39 (patch) | |
tree | 1eb94d190f7645c8c6e38999025d0d4327e51d61 /activerecord/lib/active_record/connection_adapters/abstract | |
parent | 5b95730edc33ee97f53da26a3868eb983305a771 (diff) | |
download | rails-6626833db13a69786f9f6cd56b9f53c4017c3e39.tar.gz rails-6626833db13a69786f9f6cd56b9f53c4017c3e39.tar.bz2 rails-6626833db13a69786f9f6cd56b9f53c4017c3e39.zip |
Revert "Add index length support for MySQL [#1852 state:open]"
This commit breaks dumping a few tables, as the sessions table.
To reproduce, just create a new application and:
rake db:sessions:create
rake db:migrate
rake db:test:prepare
And then look at the db/schema.rb file (ht: Sam Ruby).
This reverts commit 5b95730edc33ee97f53da26a3868eb983305a771.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 23 |
2 files changed, 2 insertions, 23 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index e42cd99786..6c477e48ce 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -258,7 +258,7 @@ module ActiveRecord end end - class IndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths) #:nodoc: + class IndexDefinition < Struct.new(:table, :name, :unique, :columns) #:nodoc: end # Abstract representation of a column definition. Instances of this type 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 1255ef09be..e8cba1bd41 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -256,32 +256,18 @@ module ActiveRecord # name. # # ===== Examples - # # ====== Creating a simple index # add_index(:suppliers, :name) # generates # CREATE INDEX suppliers_name_index ON suppliers(name) - # # ====== Creating a unique index # add_index(:accounts, [:branch_id, :party_id], :unique => true) # generates # CREATE UNIQUE INDEX accounts_branch_id_party_id_index ON accounts(branch_id, party_id) - # # ====== Creating a named index # add_index(:accounts, [:branch_id, :party_id], :unique => true, :name => 'by_branch_party') # generates # CREATE UNIQUE INDEX by_branch_party ON accounts(branch_id, party_id) - # - # ====== Creating an index with specific key length - # add_index(:accounts, :name, :name => 'by_name', :length => 10) - # generates - # CREATE INDEX by_name ON accounts(name(10)) - # - # add_index(:accounts, [:name, :surname], :name => 'by_name_surname', :length => {:name => 10, :surname => 15}) - # generates - # CREATE INDEX by_name_surname ON accounts(name(10), surname(15)) - # - # Note: SQLite doesn't support index length def add_index(table_name, column_name, options = {}) column_names = Array.wrap(column_name) index_name = index_name(table_name, :column => column_names) @@ -292,9 +278,7 @@ module ActiveRecord else index_type = options end - - quoted_column_names = quoted_columns_for_index(column_names, options).join(", ") - + quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ") execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{quoted_column_names})" end @@ -446,11 +430,6 @@ module ActiveRecord end protected - # Overridden by the mysql adapter for supporting index lengths - def quoted_columns_for_index(column_names, options = {}) - column_names.map {|name| quote_column_name(name) } - end - def options_include_default?(options) options.include?(:default) && !(options[:null] == false && options[:default].nil?) end |