Class: Exwiw::ReverseScope

Inherits:
Object
  • Object
show all
Includes:
Serdes
Defined in:
lib/exwiw/reverse_scope.rb

Overview

Opt-in configuration for multi-referencer reverse scoping (see QueryAstBuilder#build_referenced_by_clause).

A global-identity table such as users carries no scope/tenant column and has no belongs_to path of its own to the dump target; many tenant-owned tables instead point at it. The automatic single-referencer reverse extraction only narrows a table referenced by exactly one constrained child — with two or more referencers it falls back to a full dump. reverse_scope lets the schema author enumerate the referencers whose own (already-scoped) extraction queries should be UNION'd into the id set this table is constrained to:

. IN ( SELECT . FROM WHERE IS NOT NULL UNION SELECT . FROM WHERE IS NOT NULL UNION ... )

It is deliberately explicit — never inferred or emitted by the schema generators, and preserved across regeneration like the other user-owned config (see TableConfig#merge). Only referencers that are themselves scoped belong in via: an unconstrained referencer would project every row's id and union the whole table back, defeating the prune (such an arm is skipped with a warning rather than silently widening the dump).