48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/lhm/table.rb', line 48
def parse
schema = read_information_schema
Table.new(@table_name, (schema), ddl).tap do |table|
schema.each do |defn|
column_name = struct_key(defn, 'COLUMN_NAME')
column_type = struct_key(defn, 'COLUMN_TYPE')
is_nullable = struct_key(defn, 'IS_NULLABLE')
column_default = struct_key(defn, 'COLUMN_DEFAULT')
= struct_key(defn, 'COLUMN_COMMENT')
collate = struct_key(defn, 'COLLATION_NAME')
table.columns[defn[column_name]] = {
:type => defn[column_type],
:is_nullable => defn[is_nullable],
:column_default => defn[column_default],
:comment => defn[],
:collate => defn[collate],
}
end
(read_indices).each do |idx, columns|
table.indices[idx] = columns
end
end
end
|