Module: ROM::SQL::Types

Includes:
Types
Defined in:
lib/rom/sql/types.rb,
lib/rom/sql/extensions/sqlite/types.rb,
lib/rom/sql/extensions/postgres/types.rb

Constant Summary collapse

Serial =
Integer.meta(primary_key: true)
Blob =
Constructor(Sequel::SQL::Blob, &Sequel::SQL::Blob.method(:new))
Void =
Nil
SQLite =
::ROM::SQL::SQLite::Types
PG =
Postgres::Types

Class Method Summary collapse

Class Method Details

.define(value_type, &block) ⇒ Dry::Types::Nominal

Define a complex attribute type using Type DSL

Examples:

attribute :meta, Types.define(Types::JSON) do
  input { Types::PG::JSON }
  output { Types::Coercible::Hash }
end

Returns:

  • (Dry::Types::Nominal)


40
41
42
# File 'lib/rom/sql/types.rb', line 40

def self.define(value_type, &block)
  TypeDSL.new(value_type).call(&block)
end

.ForeignKey(relation, type = Types::Integer.meta(index: true)) ⇒ Dry::Types::Nominal

Define a foreign key attribute type

Examples:

with default Int type

attribute :user_id, Types.ForeignKey(:users)

with a custom type

attribute :user_id, Types.ForeignKey(:users, Types::UUID)

Returns:

  • (Dry::Types::Nominal)


25
26
27
# File 'lib/rom/sql/types.rb', line 25

def self.ForeignKey(relation, type = Types::Integer.meta(index: true))
  super
end