Class: ROM::SQL::Wrap

Inherits:
Relation::Wrap
  • Object
show all
Defined in:
lib/rom/sql/wrap.rb

Overview

Specialized wrap relation for SQL

This type of relations is returned when using ‘Relation#wrap` and it uses a join, unlike `Relation#combine` which makes separate queries. This means a relation is restricted only to tuples which have associated tuples, so it should be used in cases where you want to rely on this restriction.

Instance Method Summary collapse

Instance Method Details

#relationRelation

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Internal method used by abstract ‘ROM::Relation::Wrap`

Returns:



31
32
33
34
35
36
# File 'lib/rom/sql/wrap.rb', line 31

def relation
  relation = nodes.reduce(root) do |a, e|
    a.associations[e.name.key].join(:join, a, e)
  end
  schema.(relation)
end

#schemaSchema

Return a schema which includes attributes from wrapped relations

Returns:



22
23
24
# File 'lib/rom/sql/wrap.rb', line 22

def schema
  root.schema.merge(nodes.map(&:schema).reduce(:merge)).qualified
end