Method: Ensql::Adapter#literalize

Defined in:
lib/ensql/adapter.rb

#literalize(value) ⇒ String

Convert a Ruby object into a string that can be safely interpolated into an SQL statement. Strings will be correctly quoted. The precise result will depend on the adapter and the underlying database driver, but most RDBMs have limited ways to express literals.

Examples:

literalize("It's quoted") # => "'It''s quoted'"
literalize(1.23) # => "1.23"
literalize(true) # => "1"
literalize(nil) # => "NULL"
literalize(Time.now) # => "'2021-02-22 23:44:28.942947+1300'"

Returns:

  • (String)

    a properly quoted SQL literal

See Also:



# File 'lib/ensql/adapter.rb', line 57