Skip to content

Commit 1262c8d

Browse files
committed
fix(QuickBuilder): Preserve case for withCount and withSum
Fixes #261
1 parent 6035327 commit 1262c8d

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

models/QuickBuilder.cfc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ component accessors="true" transientCache="false" {
278278
}
279279
}
280280

281-
var subselectName = getEntity().get_str().camel( relationName & " Count" );
281+
var subselectNameArray = getEntity().get_str().words( relationName );
282+
subselectNameArray.append( "Count" );
283+
284+
var subselectName = getEntity().get_str().camel( subselectNameArray.toList( " " ) );
282285
if ( findNoCase( " as ", relationName ) ) {
283286
var parts = relationName.split( "\s(?:A|a)(?:S|s)\s" );
284287
relationName = parts[ 1 ];
@@ -339,7 +342,10 @@ component accessors="true" transientCache="false" {
339342
var attributeName = listLast( relationName, "." );
340343
relationName = listFirst( relationName, "." );
341344

342-
var subselectName = getEntity().get_str().camel( "Total " & relationName );
345+
var subselectNameArray = [ "Total" ];
346+
subselectNameArray.append( getEntity().get_str().words( relationName ), true );
347+
348+
var subselectName = getEntity().get_str().camel( subselectNameArray.toList( " " ) );
343349
if ( findNoCase( " as ", attributeName ) ) {
344350
var parts = attributeName.split( "\s(?:A|a)(?:S|s)\s" );
345351
attributeName = parts[ 1 ];

tests/specs/integration/BaseEntity/Relationships/RelationshipsAggregatesSpec.cfc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ component extends="tests.resources.ModuleIntegrationSpec" {
252252
expect( countries[ 2 ].getId() ).toBe( "02BA2DB0-EB1E-3F85-5F283AB5E45608C6" );
253253
expect( countries[ 2 ].getName() ).toBe( "Argentina" );
254254
expect( countries[ 2 ].getPostsDeepCount() ).toBe( 1 );
255+
256+
var countryMementoKeys = countries[ 2 ].getMemento().keyArray();
257+
arraySort( countryMementoKeys, "text" );
258+
expect( countryMementoKeys[ 1 ] ).toBeWithCase( "createdDate" );
259+
expect( countryMementoKeys[ 2 ] ).toBeWithCase( "id" );
260+
expect( countryMementoKeys[ 3 ] ).toBeWithCase( "modifiedDate" );
261+
expect( countryMementoKeys[ 4 ] ).toBeWithCase( "name" );
262+
expect( countryMementoKeys[ 5 ] ).toBeWithCase( "postsDeepCount" );
255263
} );
256264

257265
it( "can return the QuickBuilder instance generated for the count", function() {

0 commit comments

Comments
 (0)