Method: ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting#type_cast

Defined in:
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb

#type_cast(value) ⇒ Object

:nodoc:



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb', line 169

def type_cast(value) # :nodoc:
  case value
  when Type::Binary::Data
    # Return a bind param hash with format as binary.
    # See https://deveiate.org/code/pg/PG/Connection.html#method-i-exec_prepared-doc
    # for more information
    { value: value.to_s, format: 1 }
  when OID::Xml::Data, OID::Bit::Data
    value.to_s
  when OID::Array::Data
    encode_array(value)
  when Range
    encode_range(value)
  when Rational
    value.to_f
  else
    super
  end
end