Sha256: d9e70d97d37f9abe73907ec103950dba95961a903ef7a392711b4b501f014126

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module ROM
  module SQL
    module Postgres
      # @api private
      class TypeSerializer < ROM::SQL::TypeSerializer
        mapping(
          mapping.merge(
            SQL::Types::String => 'text',
            Types::UUID => 'uuid',
            Types::XML => 'xml',
            Types::Money => 'money',
            Types::Bytea => 'bytea',
            Types::JSON => 'json',
            Types::JSONB => 'jsonb',
            Types::HStore => 'hstore',
            Types::IPAddress => 'inet',
            Types::IPNetwork => 'cidr',
            Types::Point => 'point',
            Types::Line => 'line',
            Types::Circle => 'circle',
            Types::Box => 'box',
            Types::LineSegment => 'lseg',
            Types::Polygon => 'polygon',
            Types::Path => 'path',
            Types::Int4Range => 'int4range',
            Types::Int8Range => 'int8range',
            Types::NumRange => 'numrange',
            Types::TsRange => 'tsrange',
            Types::TsTzRange => 'tstzrange',
            Types::DateRange => 'daterange',
            Types::LTree => 'ltree'
          )
        )

        def call(type)
          super do
            if type.respond_to?(:primitive) && type.primitive.equal?(::Array)
              "#{type.meta[:type]}[]"
            end
          end
        end
      end
    end

    TypeSerializer.register(:postgres, Postgres::TypeSerializer.new.freeze)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-sql-3.7.0 lib/rom/sql/extensions/postgres/type_serializer.rb