aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-05-09 12:42:48 +0100
committerPratik Naik <pratiknaik@gmail.com>2010-05-09 12:42:48 +0100
commit8d2f6c16e381f5fff6d3f24f5c73a443577a1488 (patch)
treec79dbfcd8945652f7bf746c05043acf537affbd0 /activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
parentf75a6fec2947ce23bd3ca4911d2d798415ccd355 (diff)
downloadrails-8d2f6c16e381f5fff6d3f24f5c73a443577a1488.tar.gz
rails-8d2f6c16e381f5fff6d3f24f5c73a443577a1488.tar.bz2
rails-8d2f6c16e381f5fff6d3f24f5c73a443577a1488.zip
Revert "Revert "Add index length support for MySQL [#1852 state:open]""
This reverts commit 6626833db13a69786f9f6cd56b9f53c4017c3e39.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/mysql_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index 55d9d20bb5..470ff8d767 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -461,10 +461,11 @@ module ActiveRecord
if current_index != row[2]
next if row[2] == "PRIMARY" # skip the primary key
current_index = row[2]
- indexes << IndexDefinition.new(row[0], row[2], row[1] == "0", [])
+ indexes << IndexDefinition.new(row[0], row[2], row[1] == "0", [], [])
end
indexes.last.columns << row[4]
+ indexes.last.lengths << row[7]
end
result.free
indexes
@@ -594,6 +595,18 @@ module ActiveRecord
end
protected
+ def quoted_columns_for_index(column_names, options = {})
+ length = options[:length] if options.is_a?(Hash)
+
+ quoted_column_names = case length
+ when Hash
+ column_names.map {|name| length[name] ? "#{quote_column_name(name)}(#{length[name]})" : quote_column_name(name) }
+ when Fixnum
+ column_names.map {|name| "#{quote_column_name(name)}(#{length})"}
+ else
+ column_names.map {|name| quote_column_name(name) }
+ end
+ end
def translate_exception(exception, message)
return super unless exception.respond_to?(:errno)