method
type_cast
v4.1.8 -
Show latest stable
-
0 notes -
Class: Quoting
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- What's this?
type_cast(value, column, array_member = false)
public
Hide source
# File activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb, line 85 def type_cast(value, column, array_member = false) return super(value, column) unless column case value when Range if /range$/ =~ column.sql_type PostgreSQLColumn.range_to_string(value) else super(value, column) end when NilClass if column.array && array_member 'NULL' elsif column.array value else super(value, column) end when Array case column.sql_type when 'point' then PostgreSQLColumn.point_to_string(value) when 'json' then PostgreSQLColumn.json_to_string(value) else if column.array PostgreSQLColumn.array_to_string(value, column, self) else super(value, column) end end when String if 'bytea' == column.sql_type # Return a bind param hash with format as binary. # See http://deveiate.org/code/pg/PGconn.html#method-i-exec_prepared-doc # for more information { value: value, format: 1 } else super(value, column) end when Hash case column.sql_type when 'hstore' then PostgreSQLColumn.hstore_to_string(value, array_member) when 'json' then PostgreSQLColumn.json_to_string(value) else super(value, column) end when IPAddr if %(inet cidr).include? column.sql_type PostgreSQLColumn.cidr_to_string(value) else super(value, column) end else super(value, column) end end