Sha256: 2c84c1ff065cc3f19e163d9686b628011f317635b21f00a22070f1af0abfe650

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'sequel/core'

require 'rom/sql/type_extensions'

Sequel.extension(:pg_hstore)

module ROM
  module SQL
    module Postgres
      module Types
        def self.Type(name, type = yield)
          type.meta(db_type: name, database: 'postgres')
        end

        UUID = Type('uuid', SQL::Types::String)

        HStore = Type('hstore') do
          read = SQL::Types.Constructor(Hash, &:to_hash)

          SQL::Types.Constructor(Hash, &Sequel.method(:hstore))
            .meta(read: read)
        end

        Bytea = Type('bytea') do
          SQL::Types.Constructor(Sequel::SQL::Blob, &Sequel::SQL::Blob.method(:new))
        end

        Money = Type('money', SQL::Types::Decimal)

        XML = Type('xml', SQL::Types::String)
      end
    end

    module Types
      PG = Postgres::Types
    end
  end
end

require 'rom/sql/extensions/postgres/types/array'
require 'rom/sql/extensions/postgres/types/json'
require 'rom/sql/extensions/postgres/types/geometric'
require 'rom/sql/extensions/postgres/types/network'
require 'rom/sql/extensions/postgres/types/range'
require 'rom/sql/extensions/postgres/types/ltree'

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rom-sql-3.7.0 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.6.5 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.6.4 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.6.3 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.6.2 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.6.1 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.6.0 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.5.0 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.4.0 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.3.3 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.3.2 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.3.1 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.3.0 lib/rom/sql/extensions/postgres/types.rb
rom-sql-3.2.0 lib/rom/sql/extensions/postgres/types.rb