method
initialize_type_map
v6.0.0 -
Show latest stable
-
0 notes -
Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
- 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 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- What's this?
initialize_type_map(m = type_map)
private
Hide source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 514 def initialize_type_map(m = type_map) m.register_type "int2", Type::Integer.new(limit: 2) m.register_type "int4", Type::Integer.new(limit: 4) m.register_type "int8", Type::Integer.new(limit: 8) m.register_type "oid", OID::Oid.new m.register_type "float4", Type::Float.new m.alias_type "float8", "float4" m.register_type "text", Type::Text.new register_class_with_limit m, "varchar", Type::String m.alias_type "char", "varchar" m.alias_type "name", "varchar" m.alias_type "bpchar", "varchar" m.register_type "bool", Type::Boolean.new register_class_with_limit m, "bit", OID::Bit register_class_with_limit m, "varbit", OID::BitVarying m.alias_type "timestamptz", "timestamp" m.register_type "date", OID::Date.new m.register_type "money", OID::Money.new m.register_type "bytea", OID::Bytea.new m.register_type "point", OID::Point.new m.register_type "hstore", OID::Hstore.new m.register_type "json", Type::Json.new m.register_type "jsonb", OID::Jsonb.new m.register_type "cidr", OID::Cidr.new m.register_type "inet", OID::Inet.new m.register_type "uuid", OID::Uuid.new m.register_type "xml", OID::Xml.new m.register_type "tsvector", OID::SpecializedString.new(:tsvector) m.register_type "macaddr", OID::SpecializedString.new(:macaddr) m.register_type "citext", OID::SpecializedString.new(:citext) m.register_type "ltree", OID::SpecializedString.new(:ltree) m.register_type "line", OID::SpecializedString.new(:line) m.register_type "lseg", OID::SpecializedString.new(:lseg) m.register_type "box", OID::SpecializedString.new(:box) m.register_type "path", OID::SpecializedString.new(:path) m.register_type "polygon", OID::SpecializedString.new(:polygon) m.register_type "circle", OID::SpecializedString.new(:circle) m.register_type "interval" do |_, _, sql_type| precision = extract_precision(sql_type) OID::SpecializedString.new(:interval, precision: precision) end register_class_with_precision m, "time", Type::Time register_class_with_precision m, "timestamp", OID::DateTime m.register_type "numeric" do |_, fmod, sql_type| precision = extract_precision(sql_type) scale = extract_scale(sql_type) # The type for the numeric depends on the width of the field, # so we'll do something special here. # # When dealing with decimal columns: # # places after decimal = fmod - 4 & 0xffff # places before decimal = (fmod - 4) >> 16 & 0xffff if fmod && (fmod - 4 & 0xffff).zero? # FIXME: Remove this class, and the second argument to # lookups on PG Type::DecimalWithoutScale.new(precision: precision) else OID::Decimal.new(precision: precision, scale: scale) end end load_additional_types end