Skip to content

Honor Where clauses on the inner source of GroupJoin#4331

Merged
jeremydmiller merged 1 commit intoJasperFx:masterfrom
snrnats:group-join-filtering-improvements
May 6, 2026
Merged

Honor Where clauses on the inner source of GroupJoin#4331
jeremydmiller merged 1 commit intoJasperFx:masterfrom
snrnats:group-join-filtering-improvements

Conversation

@snrnats
Copy link
Copy Markdown
Contributor

@snrnats snrnats commented May 6, 2026

Where predicates chained onto the inner IQueryable passed to GroupJoin were silently dropped during SQL compilation. They are now extracted from the inner source expression tree and applied to the inner CTE so filtering happens before the join.

Problem

Given a query like:

await session.Query<Customer>()
    .GroupJoin(
        session.Query<Order>().Where(o => o.Status == "Shipped"),
        c => c.Id,
        o => o.CustomerId,
        (c, orders) => new { c, orders })
    .SelectMany(x => x.orders, (x, o) => new { x.c.Name, o.Amount })
    .ToListAsync();

The Where(o => o.Status == "Shipped") was completely ignored — the inner CTE was built straight from Order storage with only the default tenant/soft-delete filters.

@snrnats snrnats changed the title Implement Where filtering for the inner source of the GroupJoin Honor Where clauses on the inner source of GroupJoin May 6, 2026
@jeremydmiller
Copy link
Copy Markdown
Member

@snrnats

image

@jeremydmiller jeremydmiller merged commit bb2acf5 into JasperFx:master May 6, 2026
6 checks passed
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.

2 participants