class Naginegi::PostgreSQL::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/naginegi/postgresql.rb, line 64
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/naginegi/postgresql.rb, line 69
def bigquery_data_type
  TYPE_MAPPINGS[@data_type] || 'STRING'
end
converted_value() click to toggle source
# File lib/naginegi/postgresql.rb, line 73
def converted_value
  if bigquery_data_type == 'TIMESTAMP'
    # time zone translate to UTC
    "EXTRACT(EPOCH FROM #{escaped_column_name}) AS #{escaped_column_name}"
  else
    escaped_column_name
  end
end
to_json(*a) click to toggle source
# File lib/naginegi/postgresql.rb, line 82
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/naginegi/postgresql.rb, line 88
def escaped_column_name
  "\"#{@column_name}\""
end