class Samidare::MySQL::Column
Constants
- TYPE_MAPPINGS
Attributes
column_name[R]
data_type[R]
Public Class Methods
new(column_name, data_type)
click to toggle source
# File lib/samidare/mysql.rb, line 86 def initialize(column_name, data_type) @column_name = column_name @data_type = data_type end
Public Instance Methods
bigquery_data_type()
click to toggle source
# File lib/samidare/mysql.rb, line 91 def bigquery_data_type TYPE_MAPPINGS[@data_type] end
converted_value()
click to toggle source
# File lib/samidare/mysql.rb, line 95 def converted_value if bigquery_data_type == 'timestamp' # time zone translate to UTC "UNIX_TIMESTAMP(#{escaped_column_name}) AS #{escaped_column_name}" elsif data_type == 'tinyint' # for MySQL tinyint(1) problem "CAST(#{escaped_column_name} AS signed) AS #{escaped_column_name}" else escaped_column_name end end
to_json(*a)
click to toggle source
# File lib/samidare/mysql.rb, line 107 def to_json(*a) { "name" => @column_name, "type" => bigquery_data_type }.to_json(*a) end
Private Instance Methods
escaped_column_name()
click to toggle source
# File lib/samidare/mysql.rb, line 112 def escaped_column_name "`#{@column_name}`" end