Class: Exwiw::QueryAst::UnionSubquery
- Inherits:
-
Struct
- Object
- Struct
- Exwiw::QueryAst::UnionSubquery
- Defined in:
- lib/exwiw/query_ast.rb
Overview
A subquery that UNIONs several single-column ‘Select`s into one id set. Used by multi-referencer reverse / “referenced_by” extraction (TableConfig#reverse_scope): a parent table referenced by many scoped tables is constrained to the union of every referencer’s projected foreign key, rather than falling back to dumping every row:
<parent>.<pk> IN (
SELECT <ref1>.<col1> FROM <ref1> WHERE <ref1 scope> AND <col1> IS NOT NULL
UNION SELECT <ref2>.<col2> FROM <ref2> WHERE <ref2 scope> AND <col2> IS NOT NULL
)
Each ‘queries` element is a `Select` already projected to the foreign-key column that points at the parent (with a NULL-excluding filter).
Instance Attribute Summary collapse
-
#queries ⇒ Object
Returns the value of attribute queries.
Instance Method Summary collapse
Instance Attribute Details
#queries ⇒ Object
Returns the value of attribute queries
99 100 101 |
# File 'lib/exwiw/query_ast.rb', line 99 def queries @queries end |
Instance Method Details
#to_h ⇒ Object
100 101 102 |
# File 'lib/exwiw/query_ast.rb', line 100 def to_h { union: queries.map(&:to_h) } end |