module FlydataCore module TableDef class Base def initialize(table_def, table_name, columns, column_def, default_charset, default_source_charset, comment) @table_def = table_def @table_name = table_name @columns = columns @column_def = column_def @default_charset = default_charset @default_source_charset = default_source_charset @comment = comment end attr_reader :columns, :column_def, :table_name, :default_source_charset def to_flydata_tabledef tabledef = { table_name: @table_name, columns: @columns, } tabledef[:default_charset] = @default_charset if @default_charset tabledef[:comment] = @comment if @comment tabledef[:src_ddl] = @table_def tabledef end def column_names @columns.collect{|col| col[:column]} end def pk_columns @columns.select{|col| col.has_key?(:primary_key) }. sort{|a,b| a[:primary_key] <=> b[:primary_key]}. collect{|col| col[:column]} end end end end