instance method prepare_column_options

Ruby on Rails 4.1.16

Since v4.0.13 Last seen in v4.2.9

Available in: v4.0.13 v4.1.16 v4.2.9

Signature

prepare_column_options(column, types)

This can be overridden on a Adapter level basis to support other extended datatypes (Example: Adding an array option in the PostgreSQLAdapter)

Parameters

column req
types req
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb, line 20
      def prepare_column_options(column, types)
        spec = {}
        spec[:name]      = column.name.inspect

        # AR has an optimization which handles zero-scale decimals as integers. This
        # code ensures that the dumper still dumps the column as a decimal.
        spec[:type]      = if column.type == :integer && /^(numeric|decimal)/ =~ column.sql_type
                             'decimal'
                           else
                             column.type.to_s
                           end
        spec[:limit]     = column.limit.inspect if column.limit != types[column.type][:limit] && spec[:type] != 'decimal'
        spec[:precision] = column.precision.inspect if column.precision
        spec[:scale]     = column.scale.inspect if column.scale
        spec[:null]      = 'false' unless column.null
        spec[:default]   = default_string(column.default) if column.has_default?
        spec
      end

Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb line 20 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::ColumnDumper

Type at least 2 characters to search.

↑↓ navigate · open · esc close