Repository navigation
feat(query): add a relationship method for related document queries - #14502
Conversation
utopia-php/database populates related documents itself and needs a query that carries queries written against the related collection, so a caller can filter, order, select and paginate the documents populated for one relationship attribute. The method set is this enum, which consumers cannot extend, so the method has to live here. It is nested so its children parse, serialize and fingerprint like an and/or's. validate() skips it because its children name another collection's attributes, and no bundled builder compiles it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR introduces a
The implementation matches the documented contract: no bundled builder silently miscompiles the new method, and the parse/serialize round-trip and shape handling check out. One advisory note: the new public API ships in a Reviewed commit: bbb4479 |
🟢 Tier S · Ready to merge
Adds Latest changes: The newest commits add unsupported-filter regression tests for relationship queries in the ClickHouse, MongoDB, and MySQL builders.
📂 Walkthrough · 9
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The README promises no bundled builder compiles a relationship query, as with elemMatch, so the MySQL, ClickHouse and MongoDB builder tests now assert the UnsupportedException a dialect throws for one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nship Relationship queries need a method in the query library's Method enum, which this library cannot extend. appwrite/appwrite#14502 adds it; until it is released as 0.7.1 this tracks its dev split. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
Adds
Method::RelationshipandQuery::relationship(string $attribute, array $queries)topackages/query, released asutopia-php/query0.7.1.isNested()is true, so the children parse and serialize as queries.LOGICAL_TYPES, so the children count towardshape()andfingerprint(). Two relationship queries with different inner shapes don't collide.Query::validate()skips it, because its children name another collection's attributes.UnsupportedException, the same as forelemMatch.Why
utopia-php/database#968 (nested relationship queries) lets callers filter, order, select and paginate the documents populated for one relationship attribute. Since 0.7 the database library builds its queries on this package's
Methodenum. A backed enum can't be extended downstream, so the method has to be added here. Encoding it some other way in the database library, for example by reusingelemMatch, would give one method two meanings.Verification
bin/monorepo check query: pint, phpstan and rector are clean.phpunit --testsuite unit --exclude-group=performanceinpackages/query: 5459 tests pass. New tests cover the factory,isNested(), the parse round trip, shape and fingerprint, and thevalidate()skip.Not verified
dev-split of this branch until 0.7.1 is tagged.🤖 Generated with Claude Code