Method: Spider::Model::Storage::Db::Mysql#dump_value
- Defined in:
- lib/spiderfw/model/storage/db/adapters/mysql.rb
#dump_value(val, field) ⇒ Object
475 476 477 478 479 480 481 482 483 484 485 486 |
# File 'lib/spiderfw/model/storage/db/adapters/mysql.rb', line 475 def dump_value(val, field) return 'NULL' if val.nil? type = self.class.field_types[field.type] if ['CHAR', 'VARCHAR', 'BLOB', 'TINY_BLOB', 'MEDIUM_BLOB', 'LONG_BLOB'].include?(type) val = val.gsub("'", "''").gsub("\n", '\n').gsub("\r", '\r') return "'#{val}'" elsif ['DATE', 'TIME', 'DATETIME'].include?(type) return "'#{val}'" else return val.to_s end end |