Sha256: 44a32c4c47a6cf643c0b72e59ce426a45930051c9116fa2ca86950e2057c29d0

Contents?: true

Size: 1.1 KB

Versions: 9

Compression:

Stored size: 1.1 KB

Contents

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

9 entries across 9 versions & 1 rubygems

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