Sha256: 2d069eaa2e952f0dafedc51095d977d58e650905cceaa88657fc6e53c240ff19

Contents?: true

Size: 1.35 KB

Versions: 9

Compression:

Stored size: 1.35 KB

Contents

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::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

9 entries across 9 versions & 1 rubygems

Version Path
rom-sql-3.1.0 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-3.0.1 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-3.0.0 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-2.5.0 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-2.4.0 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-2.3.0 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-2.2.1 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-2.2.0 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-2.1.0 lib/rom/sql/extensions/postgres/type_serializer.rb