buildPolymorphicJoinVariable.php
Table of Contents
Functions
- buildPolymorphicJoinVariable() : string
- Builds a single AQL 'LET' subquery for a *polymorphic* join — a join whose target collection is chosen at query time from a discriminator field of the parent document.
Functions
buildPolymorphicJoinVariable()
Builds a single AQL 'LET' subquery for a *polymorphic* join — a join whose target collection is chosen at query time from a discriminator field of the parent document.
buildPolymorphicJoinVariable(string|null $name[, array<string|int, mixed> $definition = [] ][, string $docRef = AQL::DOC ][, ContainerInterface|null $container = null ][, array<string|int, mixed> $init = [] ][, bool $isArray = false ]) : string
The whole branch machinery (guarding, per-branch permission gating, the
FALLBACK branch, the APPEND combine) lives in the shared
buildPolymorphicRelationVariable(); this function only resolves the
join-specific shared defaults — the parent key path (Arango::PROPERTY,
defaulting to $name) and the foreign key attribute (Arango::KEY) — and
supplies the per-branch builder that wraps buildJoinSubquery().
The resulting LET always holds an array — exactly like a regular join —
so the projection layer (aqlFieldObject())
unwraps it with FIRST() for a Filter::JOIN or keeps the whole array for a
Filter::JOINS.
Example output (single Filter::JOIN, two branches):
LET area = APPEND(
( FOR doc_join IN warehouses
FILTER doc_join._key == doc.selector.areaServed
&& doc.selector.areaScope == "…#Warehouse"
RETURN { _key: doc_join._key, name: doc_join.name } ) ,
( FOR doc_join IN subsidiaries
FILTER doc_join._key == doc.selector.areaServed
&& doc.selector.areaScope == "…#Company"
RETURN { _key: doc_join._key, name: doc_join.name } )
)
Parameters
- $name : string|null
-
The join field name — also the default
LETvariable name and the default parent key path. - $definition : array<string|int, mixed> = []
-
The polymorphic join definition. Keys:
Arango::DISCRIMINATOR(string) Parent field path deciding the branch (required).Arango::MAP(array) Non-emptytype => join-definitiontable (required).Arango::PROPERTY(string|null) Shared parent key path (default:$name).Arango::KEY(string|null) Shared foreign key attribute (default per branch:_key).Arango::UNIQUE(string|null) OptionalLETvariable name, overrides$name.Arango::FALLBACK(array|null) Join definition for unmatched discriminator values (null= none).
- $docRef : string = AQL::DOC
-
The AQL variable name of the main document reference.
- $container : ContainerInterface|null = null
-
Optional DI container used to resolve branch models.
- $init : array<string|int, mixed> = []
-
Optional associative array used for variable initialization.
- $isArray : bool = false
-
If true, each branch matches an array of keys (
IN).
Tags
Return values
string —The complete AQL 'LET' statement.