Skip to content

feat(search): _referenced filters objects by a field of the row their property references - #4678

Merged
rubenvdlinde merged 1 commit into
developmentfrom
feat/referenced-row-filter
Oct 17, 2026
Merged

rubenvdlinde merged 1 commit into
developmentfrom
feat/referenced-row-filter

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

What

_referenced[<schema>][<property>][<field>]=<value> on the object search: objects whose OWN <property> holds the uuid of a row of <schema> that satisfies the conditions. The forward twin of _related (which only asks about rows pointing AT the object), with the same grammar (operators eq ne gt gte lt lte in, lists as in, numbered blocks for "two different rows") and the same refusals (an unusable block or an unknown schema is a 400-class error, never a dropped filter).

GET /api/objects/dossiq/subsidieBeschikking?_referenced[subsidieAanvraag][subsidieaanvraag][case]=<case uuid>

returns the beschikkingen whose subsidieaanvraag points at an application of that case.

Authorization

Each block becomes EXISTS (SELECT 1 FROM <referenced table> rel WHERE rel._uuid = t.<property> AND rel._deleted IS NULL AND (<referenced schema's read predicate>) AND <conditions>). The predicate is MagicRbacHandler::buildRbacPredicateForAlias(<referenced schema>, alias, 'read'), the same one _related uses, and the clause refuses to render without it. So a referenced row the caller may not read never decides which objects they see; the outer schema's own RBAC is applied as before.

Also fixed (same clause)

A property or condition field written as the schema spells it (propertyDefinition) is now read from its snake-case magic-table column (property_definition), for _related too. It was quoted as written, a column that does not exist. Snake-case names are unchanged.

Why

Board DqSubsidie lists beschikkingen, voorschotten and vaststellingen on a case; those rows reference the subsidy application, not the case. Today ?subsidieaanvraag.case=X on a uuid property is silently read as subsidieaanvraag IN ('X'): an empty list, no error.

Not in scope

Facets over _referenced and the multi-schema raw UNION search path; neither supports _related either.

Consumer

No nextcloud-vue change: a manifest filter written with the flat bracket key passes through buildQueryString as written and its value takes tokens: { "_referenced[subsidieAanvraag][subsidieaanvraag][case]": "@objectId" }.

Verified locally

  • tests/Unit/Service/Query/ 39 tests (6 new in ReferencedRowFilterTest: parse direction, refusal naming _referenced, forward join on columns and on JSON storage, camel-case column, applier with the referenced schema's RBAC predicate), MagicSearchHandlerTest 25, MagicSearchHandlerMetadataOperatorTest 17: all OK. The new tests fail on development (no direction, no _referenced).
  • phpcs and phpmd on changed files: no findings on changed lines.
  • composer check:strict once: lint, migration-version, phpcs, phpmd, psalm ("No errors found"), phpstan ("No errors") green; test:all 26,291 tests, 15 errors, the same inherited AuditTrail* / DraftRemovalAuditRow DB tests that need the server's OC\DB\Schema\Table (also red on development, recorded on feat(flow-runs): per-flow run summary, and since/flowIds on the run history #4672 and feat(flow): each step records when it started, and a node can write log lines #4674).

AI-assisted: written with Claude Code.

… property references

The forward twin of _related: an EXISTS subquery joined referenced._uuid =
object.<property>, carrying the referenced schema's own read access
predicate, same grammar and refusals. A camel-case property reads its
snake-case magic-table column in both directions.

Assisted-by: ClaudeCode:claude-opus-5-5
@rubenvdlinde
rubenvdlinde merged commit e89e8e4 into development Oct 17, 2026
39 checks passed
@rubenvdlinde
rubenvdlinde deleted the feat/referenced-row-filter branch October 17, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant