use our own index def class for better compatibility across ActiveRecord versions

This commit is contained in:
Brian Lopez 2010-10-27 15:36:25 -07:00
parent 426cff8adc
commit 90ddb63e52
1 changed files with 4 additions and 1 deletions

View File

@ -18,6 +18,9 @@ module ActiveRecord
end end
module ConnectionAdapters module ConnectionAdapters
class Mysql2IndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths) #:nodoc:
end
class Mysql2Column < Column class Mysql2Column < Column
BOOL = "tinyint(1)" BOOL = "tinyint(1)"
def extract_default(default) def extract_default(default)
@ -447,7 +450,7 @@ module ActiveRecord
if current_index != row[:Key_name] if current_index != row[:Key_name]
next if row[:Key_name] == PRIMARY # skip the primary key next if row[:Key_name] == PRIMARY # skip the primary key
current_index = row[:Key_name] current_index = row[:Key_name]
indexes << IndexDefinition.new(row[:Table], row[:Key_name], row[:Non_unique] == 0, [], []) indexes << Mysql2IndexDefinition.new(row[:Table], row[:Key_name], row[:Non_unique] == 0, [], [])
end end
indexes.last.columns << row[:Column_name] indexes.last.columns << row[:Column_name]