Skip to content

Commit 70b1710

Browse files
committed
fix(QueryUtils): Minor fix for isQuickBuilder checks on BoxLang
BoxLang doesn't allow checking closures as structs, so this ensures we never try to.
1 parent 59eea3c commit 70b1710

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

models/QuickBuilder.cfc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ component accessors="true" transientCache="false" {
189189
} );
190190
} );
191191
q.select( q.raw( 1 ) );
192-
if ( structKeyExists( qb, "isQuickBuilder" ) ) {
192+
if ( isStruct( qb ) && structKeyExists( qb, "isQuickBuilder" ) ) {
193193
q.getQB();
194194
}
195195
var relationshipQuery = relationship.addCompareConstraints( q );
196-
if ( structKeyExists( relationshipQuery, "getRelationshipBuilder" ) ) {
196+
if ( isStruct( relationshipQuery ) && structKeyExists( relationshipQuery, "getRelationshipBuilder" ) ) {
197197
relationshipQuery = relationshipQuery.getRelationshipBuilder();
198198
}
199-
if ( structKeyExists( relationshipQuery, "isQuickBuilder" ) ) {
199+
if ( isStruct( relationshipQuery ) && structKeyExists( relationshipQuery, "isQuickBuilder" ) ) {
200200
relationshipQuery = relationshipQuery.getQB();
201201
}
202202
q = relationship.whereExists( relationshipQuery );
@@ -208,11 +208,11 @@ component accessors="true" transientCache="false" {
208208

209209
subselectQuery.limit( 1 )
210210

211-
if ( structKeyExists( subselectQuery, "getRelationshipBuilder" ) ) {
211+
if ( isStruct( subselectQuery ) && structKeyExists( subselectQuery, "getRelationshipBuilder" ) ) {
212212
subselectQuery = subselectQuery.getRelationshipBuilder();
213213
}
214214

215-
if ( structKeyExists( subselectQuery, "isQuickBuilder" ) ) {
215+
if ( isStruct( subselectQuery ) && structKeyExists( subselectQuery, "isQuickBuilder" ) ) {
216216
subselectQuery = subselectQuery.getQB();
217217
}
218218

@@ -666,7 +666,7 @@ component accessors="true" transientCache="false" {
666666

667667
var existsQuery = relationship.addCompareConstraints( q.select( q.raw( 1 ) ) ).clearOrders();
668668

669-
if ( structKeyExists( existsQuery, "isQuickBuilder" ) ) {
669+
if ( isStruct( existsQuery ) && structKeyExists( existsQuery, "isQuickBuilder" ) ) {
670670
existsQuery = existsQuery.getQB();
671671
}
672672

@@ -677,11 +677,11 @@ component accessors="true" transientCache="false" {
677677

678678
q.select( arguments.columnName );
679679

680-
if ( structKeyExists( q, "relationshipClass" ) ) {
680+
if ( isStruct( q ) && structKeyExists( q, "relationshipClass" ) ) {
681681
q = q.retrieveQuery();
682682
}
683683

684-
if ( structKeyExists( q, "isQuickBuilder" ) ) {
684+
if ( isStruct( q ) && structKeyExists( q, "isQuickBuilder" ) ) {
685685
q = q.getQB();
686686
}
687687

@@ -1336,7 +1336,7 @@ component accessors="true" transientCache="false" {
13361336
* @returns quick.models.BaseEntity
13371337
*/
13381338
public any function populateQuery( required any query ) {
1339-
if ( structKeyExists( arguments.query, "isQuickBuilder" ) ) {
1339+
if ( isStruct( arguments.query ) && structKeyExists( arguments.query, "isQuickBuilder" ) ) {
13401340
arguments.query = arguments.query.getQB();
13411341
}
13421342
variables.qb = arguments.query;

models/QuickQB.cfc

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ component
7777
* @return qb.models.Query.QueryBuilder
7878
*/
7979
public QuickQB function fromSub( required string alias, required any input ) {
80-
if ( structKeyExists( arguments.input, "isQuickBuilder" ) ) {
80+
if ( isStruct( arguments.input ) && structKeyExists( arguments.input, "isQuickBuilder" ) ) {
8181
arguments.input = arguments.input.getQB();
8282
}
8383

@@ -110,7 +110,7 @@ component
110110
string type = "inner",
111111
boolean where = false
112112
) {
113-
if ( structKeyExists( arguments.input, "isQuickBuilder" ) ) {
113+
if ( isStruct( arguments.input ) && structKeyExists( arguments.input, "isQuickBuilder" ) ) {
114114
arguments.input = arguments.input.getQB();
115115
}
116116

@@ -133,7 +133,7 @@ component
133133
query,
134134
combinator = "and"
135135
) {
136-
if ( structKeyExists( arguments.query, "isQuickBuilder" ) ) {
136+
if ( isStruct( arguments.query ) && structKeyExists( arguments.query, "isQuickBuilder" ) ) {
137137
arguments.query = arguments.query.getQB();
138138
}
139139

@@ -149,7 +149,7 @@ component
149149
* @return qb.models.Query.QueryBuilder
150150
*/
151151
public QuickQB function orderBySub( required any query, string direction = "asc" ) {
152-
if ( structKeyExists( arguments.query, "isQuickBuilder" ) ) {
152+
if ( isStruct( arguments.query ) && structKeyExists( arguments.query, "isQuickBuilder" ) ) {
153153
arguments.query = arguments.query.getQB();
154154
}
155155

@@ -169,7 +169,7 @@ component
169169
* @return qb.models.Query.QueryBuilder
170170
*/
171171
public QuickQB function crossJoinSub( required any alias, required any input ) {
172-
if ( structKeyExists( arguments.input, "isQuickBuilder" ) ) {
172+
if ( isStruct( arguments.input ) && structKeyExists( arguments.input, "isQuickBuilder" ) ) {
173173
arguments.input = arguments.input.getQB();
174174
}
175175

@@ -190,7 +190,7 @@ component
190190
combinator = "and",
191191
negate = false
192192
) {
193-
if ( structKeyExists( arguments.query, "isQuickBuilder" ) ) {
193+
if ( isStruct( arguments.query ) && structKeyExists( arguments.query, "isQuickBuilder" ) ) {
194194
arguments.query = arguments.query.getQB();
195195
}
196196

@@ -235,7 +235,7 @@ component
235235
* @return qb.models.Query.QueryBuilder
236236
*/
237237
public QueryBuilder function union( required any input, boolean all = false ) {
238-
if ( structKeyExists( arguments.input, "isQuickBuilder" ) ) {
238+
if ( isStruct( arguments.input ) && structKeyExists( arguments.input, "isQuickBuilder" ) ) {
239239
arguments.input = arguments.input.getQB();
240240
}
241241

@@ -258,7 +258,7 @@ component
258258
array columns = [],
259259
boolean recursive = false
260260
) {
261-
if ( structKeyExists( arguments.input, "isQuickBuilder" ) ) {
261+
if ( isStruct( arguments.input ) && structKeyExists( arguments.input, "isQuickBuilder" ) ) {
262262
arguments.input = arguments.input.getQB();
263263
}
264264

@@ -282,7 +282,7 @@ component
282282
struct options = {},
283283
boolean toSql = false
284284
) {
285-
if ( structKeyExists( arguments.source, "isQuickBuilder" ) ) {
285+
if ( isStruct( arguments.source ) && structKeyExists( arguments.source, "isQuickBuilder" ) ) {
286286
arguments.source = arguments.source.getQB();
287287
}
288288

@@ -306,7 +306,7 @@ component
306306
boolean toSql = false
307307
) {
308308
for ( var key in arguments.values ) {
309-
if ( structKeyExists( arguments.values[ key ], "isQuickBuilder" ) ) {
309+
if ( isStruct( arguments.values[ key ] ) && structKeyExists( arguments.values[ key ], "isQuickBuilder" ) ) {
310310
arguments.values[ key ] = arguments.values[ key ].getQb();
311311
}
312312
}
@@ -323,7 +323,12 @@ component
323323
struct options = {},
324324
boolean toSql = false
325325
) {
326-
if ( !isNull( arguments.source ) && structKeyExists( arguments.source, "isQuickBuilder" ) ) {
326+
if (
327+
!isNull( arguments.source ) && isStruct( arguments.source ) && structKeyExists(
328+
arguments.source,
329+
"isQuickBuilder"
330+
)
331+
) {
327332
arguments.source = arguments.source.getQB();
328333
}
329334

@@ -339,7 +344,7 @@ component
339344
* @returns qb.models.Query.QueryBuilder
340345
*/
341346
public QueryBuilder function subSelect( required string alias, required any query ) {
342-
if ( structKeyExists( arguments.query, "isQuickBuilder" ) ) {
347+
if ( isStruct( arguments.query ) && structKeyExists( arguments.query, "isQuickBuilder" ) ) {
343348
arguments.query = arguments.query.getQB();
344349
}
345350

@@ -361,7 +366,7 @@ component
361366
negate = false
362367
) {
363368
if (
364-
!isClosure( arguments.query ) && !isCustomFunction( arguments.query ) && structKeyExists(
369+
!isClosure( arguments.query ) && !isCustomFunction( arguments.query ) && isStruct( arguments.query ) && structKeyExists(
365370
arguments.query,
366371
"isQuickBuilder"
367372
)

tests/Application.cfc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ component {
1414
this.mappings[ "/tests" ] = testsPath;
1515
rootPath = REReplaceNoCase( this.mappings[ "/tests" ], "tests(\\|/)", "" );
1616
this.mappings[ "/root" ] = rootPath;
17-
this.mappings[ "/testingModuleRoot" ] = listDeleteAt( rootPath, listLen( rootPath, '\/' ), "\/" );
18-
this.mappings[ "/quick" ] = listDeleteAt( rootPath, listLen( rootPath, '\/' ), "\/" );
17+
testingModuleRootMapping = listDeleteAt( rootPath, listLen( rootPath, '\/' ), "\/" );
18+
if ( left( testingModuleRootMapping, 1 ) != "/" ) {
19+
testingModuleRootMapping = "/" & testingModuleRootMapping;
20+
}
21+
this.mappings[ "/testingModuleRoot" ] = testingModuleRootMapping;
22+
this.mappings[ "/quick" ] = testingModuleRootMapping;
1923
this.mappings[ "/qb" ] = rootPath & "/modules/qb";
2024
this.mappings[ "/app" ] = testsPath & "resources/app";
2125
this.mappings[ "/coldbox" ] = testsPath & "resources/app/coldbox";

0 commit comments

Comments
 (0)