Skip to content

Fix AnyTenant() with child collection Any() in separate Where clauses (GH-4146)#4150

Merged
jeremydmiller merged 1 commit intomasterfrom
GH4146
Feb 24, 2026
Merged

Fix AnyTenant() with child collection Any() in separate Where clauses (GH-4146)#4150
jeremydmiller merged 1 commit intomasterfrom
GH4146

Conversation

@jeremydmiller
Copy link
Member

Summary

  • Fixes AnyTenant results in filtering by tenant #4146AnyTenant() in a separate .Where() clause from a child collection .Any() query was still filtering by tenant_id
  • Root cause: SubQueryFilter.Apply() hardcoded a tenant_id filter based on builder.TenantId, regardless of whether AnyTenant() was specified
  • Added BypassTenantFilter flag to SubQueryFilter, set during compileAnySubQueries when AnyTenant() is detected among the top-level filters

Test plan

  • New test: any_tenant_with_child_collection_any_in_separate_where_clauses verifies SQL does not contain tenant_id
  • Existing tests in Bug_1884_multi_tenancy_and_Any_query still pass
  • Full LinqTests suite: 1208 passed, 1 skipped, 0 failures
  • CI passes

🤖 Generated with Claude Code

When AnyTenant() was in a separate .Where() clause from a child collection
.Any() query, SubQueryFilter.Apply() still hardcoded a tenant_id filter
based on the builder's TenantId. Added BypassTenantFilter flag to
SubQueryFilter, set during compileAnySubQueries when AnyTenant() is
detected among the top-level filters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 3cab72d into master Feb 24, 2026
6 of 7 checks passed
@jeremydmiller jeremydmiller deleted the GH4146 branch February 24, 2026 17:13
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.

AnyTenant results in filtering by tenant

1 participant