Sha256: b2083dae9f4e53c01c9ba9663e782eb01476e689bed803f47961ed45a5b79ad3

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 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'
          )
        )

        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

3 entries across 3 versions & 1 rubygems

Version Path
rom-sql-2.0.0 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-2.0.0.rc1 lib/rom/sql/extensions/postgres/type_serializer.rb
rom-sql-2.0.0.beta3 lib/rom/sql/extensions/postgres/type_serializer.rb