From a5c4ede851d2842447f9d957f818778fa52539d0 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Sat, 22 Aug 2026 05:51:29 -0600 Subject: [PATCH] Test scoped subselects with all Closes #60 --- tests/specs/integration/BaseEntity/SubqueriesSpec.cfc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/specs/integration/BaseEntity/SubqueriesSpec.cfc b/tests/specs/integration/BaseEntity/SubqueriesSpec.cfc index 8ccfc789..80604396 100644 --- a/tests/specs/integration/BaseEntity/SubqueriesSpec.cfc +++ b/tests/specs/integration/BaseEntity/SubqueriesSpec.cfc @@ -29,6 +29,17 @@ component extends="tests.resources.ModuleIntegrationSpec" { ); } ); + it( "keeps scoped subselects when retrieving all entities", function() { + var users = getInstance( "User" ).withLatestPostId().all(); + + expect( users ).toHaveLength( 5 ); + expect( users[ 1 ].getLatestPostId() ).toBe( 523526 ); + expect( variables.queries ).toHaveLength( + 1, + "Only one query should have been executed. #arrayLen( variables.queries )# were instead." + ); + } ); + it( "can add a subquery to an entity using a relationship", function() { var elpete = getInstance( "User" ).withLatestPostIdRelationship().findOrFail( 1 ); expect( elpete.getLatestPostId() ).notToBeNull();