Skip to content

Commit c256046

Browse files
committed
test(sql-orm-client): clarify the FK-include control case in the M:N suite
The test asserting that a 1:N FK include still lowers without a junction join carried an opaque name ("FK include path is unchanged (no regression)") that didn't say what it checks or how it relates to M:N. Rename it to state the asserted lowering and add a comment marking it as the control case for the junction-join branch — it pins that the branch fires only for N:M relations and never leaks into the FK include path. Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
1 parent dc5bdc0 commit c256046

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/3-extensions/sql-orm-client/test/query-plan-select.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,13 @@ describe('M:N include correlated subquery', () => {
759759
);
760760
});
761761

762-
it('FK include path is unchanged (no regression)', () => {
762+
// Control case for the M:N lowering above: an ordinary 1:N FK include
763+
// (users → posts, joined by posts.user_id = users.id) must still lower to a
764+
// correlated subquery whose child SELECT has NO junction JOIN and correlates
765+
// with a plain WHERE on the child's FK column. This pins that the
766+
// junction-join branch fires only for N:M relations and never leaks into the
767+
// FK include path.
768+
it('1:N FK include lowers to a child-FK WHERE with no junction join', () => {
763769
const { collection } = createCollection();
764770
const state = collection.include('posts').state;
765771

@@ -773,7 +779,6 @@ describe('M:N include correlated subquery', () => {
773779
expectDerivedTableSource(childRowsSelect);
774780
const childSelect = childRowsSelect.query;
775781

776-
// FK path: no JOIN to junction, just WHERE on child FK
777782
expect(childSelect.joins ?? []).toHaveLength(0);
778783
expect(childSelect.where).toEqual(
779784
BinaryExpr.eq(ColumnRef.of('posts', 'user_id'), ColumnRef.of('users', 'id')),

0 commit comments

Comments
 (0)