diff --git a/lib/lhm/table.rb b/lib/lhm/table.rb index 7ff30fd2..030d5603 100644 --- a/lib/lhm/table.rb +++ b/lib/lhm/table.rb @@ -40,7 +40,7 @@ def initialize(table_name, connection) def ddl sql = "show create table `#{ @table_name }`" specification = nil - @connection.execute(sql).each { |row| specification = row.last } + @connection.execute(sql).each { |row| specification = specification(row) } specification end @@ -111,6 +111,14 @@ def extract_primary_key(schema) keys.length == 1 ? keys.first : keys end + + def specification(row) + if row.is_a?(Array) + row.last + else + row["Create Table"] + end + end end end end