Class: Chicago::ETL::MysqlFileSerializer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/chicago/etl/mysql_file_serializer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#serialize(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Transforms a value to be suitable for use in file in a LOAD DATA INFILE mysql statement.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chicago/etl/mysql_file_serializer.rb', line 9

def serialize(value)
  case value
  when nil
    "NULL"
  when true
    "1"
  when false
    "0"
  when Time, DateTime
    value.strftime("%Y-%m-%d %H:%M:%S")
  when Date
    value.strftime("%Y-%m-%d")
  else
    value
  end
end