114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/myq/core.rb', line 114
def generate_value(record, column)
value = record[column['COLUMN_NAME']]
return 'NULL' if value.nil?
if value.class == String
time = to_time_or_nil(value)
if !time.nil?
return "'" + time.strftime('%Y-%m-%d %H:%M:%S') + "'"
end
max_length = column['CHARACTER_MAXIMUM_LENGTH']
return "'" + Mysql2::Client.escape(value) + "'" if max_length.nil?
value = value.size > max_length ? value.slice(0, max_length) : value
return "'" + Mysql2::Client.escape(value) + "'"
elsif value.class == Hash
escaped = Mysql2::Client.escape(Yajl::Encoder.encode(value))
return "'" + escaped + "'"
end
"'#{value}'"
end
|