-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Subselects): Add subselect helper
The subselect helper will ensure you can access your property via getters. The property cannot be updated or inserted. It additionally ensures the original columns are selected (if needed) and limits the result of the subquery to 1.
- Loading branch information
Showing
3 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
component extends="tests.resources.ModuleIntegrationSpec" appMapping="/app" { | ||
|
||
function beforeAll() { | ||
super.beforeAll(); | ||
controller.getInterceptorService().registerInterceptor( interceptorObject = this ); | ||
} | ||
|
||
function run() { | ||
describe( "Subqueries Spec", function() { | ||
beforeEach( function() { | ||
variables.queries = []; | ||
} ); | ||
|
||
it( "can add a subquery to an entity", function() { | ||
var elpete = getInstance( "User" ).withLatestPostId().findOrFail( 1 ); | ||
expect( elpete.getLatestPostId() ).notToBeNull(); | ||
expect( elpete.getLatestPostId() ).toBe( 523526 ); | ||
expect( variables.queries ).toHaveLength( 1, "Only one query should have been executed. #arrayLen( variables.queries )# were instead." ); | ||
} ); | ||
} ); | ||
} | ||
|
||
function preQBExecute( event, interceptData, buffer, rc, prc ) { | ||
arrayAppend( variables.queries, interceptData ); | ||
} | ||
|
||
} |