Flowdock
method

type_cast

Importance_0
Ruby on Rails latest stable (v6.1.7.7) - 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

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

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
Register or log in to add new notes.