Module: SqlMunger::ValueQuoter

Included in:
Quoter::DefaultQuoter
Defined in:
lib/sql_munger/value_quoter.rb

Overview

Quote a value in default SQL standard style. Probably won’t work for many backends, so the quote method from, for example, DBI should be used.

Instance Method Summary collapse

Instance Method Details

#quote(value) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sql_munger/value_quoter.rb', line 9

def quote( value )
  case value
    when NilClass
      "null"
    
    when Numeric
      value
    
    when DateTime
      # 2004-10-19 10:23:54
      "'#{value.strftime "%Y-%m-%d %H:%M:%S"}'"
    
    when Date, Time
      "'#{value}'"
      
    else
      "'#{escape( value  )}'"
  end
end