Skip to content

fix(plugin-multi-tenant): hasMany tenant fields double-wrap arrays in filterOptions#15709

Merged
PatrikKozak merged 1 commit intomainfrom
fix/plugin-multi-tenant-hasmany-array-wrapping
Feb 23, 2026
Merged

fix(plugin-multi-tenant): hasMany tenant fields double-wrap arrays in filterOptions#15709
PatrikKozak merged 1 commit intomainfrom
fix/plugin-multi-tenant-hasmany-array-wrapping

Conversation

@PatrikKozak
Copy link
Contributor

@PatrikKozak PatrikKozak commented Feb 20, 2026

What

Fixes double-wrapped arrays in filterOptions queries when tenant field has hasMany: true

Why

When a collection uses hasMany: true on the tenant field, documents store tenant IDs as arrays (e.g., tenant: [id1, id2]).

The filterDocumentsByTenants function was always wrapping the tenant value in an array without checking configuration, causing { tenant: { in: [[id1, id2]] } } instead of { tenant: { in: [id1, id2] } }.

This breaks relationship field filtering in the admin UI.

How

Added explicit hasMany parameter threaded through addFilterOptionsToFieldsaddRelationshipFilterfilterDocumentsByTenants.

When hasMany is true and docTenantID is provided, the value is used directly (already an array). Otherwise, it's wrapped in an array.

Fixes #15690

@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

@PatrikKozak PatrikKozak force-pushed the fix/plugin-multi-tenant-hasmany-array-wrapping branch from 3d1ec4a to b4f1022 Compare February 23, 2026 15:26
@PatrikKozak PatrikKozak merged commit aaddeac into main Feb 23, 2026
305 checks passed
@PatrikKozak PatrikKozak deleted the fix/plugin-multi-tenant-hasmany-array-wrapping branch February 23, 2026 15:58
@github-actions
Copy link
Contributor

🚀 This is included in version v3.78.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plugin-multi-tenant] hasMany tenant selection not respected in filters (array treated as single value)

2 participants