class ROM::SQL::Wrap

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.

@api public

Public Instance Methods

relation() click to toggle source

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

@return [Relation]

@api private

# 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
schema() click to toggle source

Return a schema which includes attributes from wrapped relations

@return [Schema]

@api public

# File lib/rom/sql/wrap.rb, line 22
def schema
  root.schema.merge(nodes.map(&:schema).reduce(:merge)).qualified
end