From 66d4c5be590f8be0315232b528663c3377dbcb73 Mon Sep 17 00:00:00 2001 From: Andrei Gliga Date: Tue, 27 Oct 2015 18:44:59 +0200 Subject: [PATCH] set the specification from an Array or a Hash the mysql2 gem returns an Array but the activerecord-jdbcmysql-adapter stores the data into a hash that looks like this: {"Table"=>"servers", "Create Table"=>"CREATE TABLE `servers`} --- lib/lhm/table.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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