Module: Og::MysqlUtils
Instance Method Summary
collapse
Methods included from SqlUtils
#blob, #build_join_name, #create_join_table_sql, #date, #join_class_ordering, #join_object_ordering, #join_table, #join_table_index, #join_table_info, #join_table_key, #join_table_keys, #ordered_join_table_keys, #parse_blob, #parse_boolean, #parse_date, #parse_float, #parse_int, #parse_timestamp, #table, #tableize, #timestamp
Instance Method Details
#escape(str) ⇒ Object
66
67
68
69
|
# File 'lib/og/store/mysql.rb', line 66
def escape(str)
return nil unless str
return Mysql.quote(str)
end
|
#quote(val) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/og/store/mysql.rb', line 71
def quote(val)
case val
when Fixnum, Integer, Float
val ? val.to_s : 'NULL'
when String
val ? "'#{escape(val)}'" : 'NULL'
when Time
val ? "'#{timestamp(val)}'" : 'NULL'
when Date
val ? "'#{date(val)}'" : 'NULL'
when TrueClass
val ? "'1'" : 'NULL'
else
val ? escape(val.to_yaml) : ''
end
end
|