Skip to content

Commit cdebb52

Browse files
committed
fix(QuickBuilder): Fix for potential scope walking bug
While not completely reproducible, some cases would find a `url.id` value before the closed over `arguments.id`. This approach avoids the problem altogether.
1 parent 27a871f commit cdebb52

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

models/QuickBuilder.cfc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -867,14 +867,13 @@ component accessors="true" transientCache="false" {
867867
}
868868
);
869869
activateGlobalScopes();
870-
return this
871-
.where( function( q ) {
872-
var allKeyNames = getEntity().keyNames();
873-
for ( var i = 1; i <= allKeyNames.len(); i++ ) {
874-
q.where( allKeyNames[ i ], id[ i ] );
875-
}
876-
} )
877-
.first( arguments.options );
870+
var idQuery = variables.qb.forNestedWhere();
871+
var allKeyNames = getEntity().keyNames();
872+
for ( var i = 1; i <= allKeyNames.len(); i++ ) {
873+
idQuery.where( allKeyNames[ i ], arguments.id[ i ] );
874+
}
875+
variables.qb.addNestedWhereQuery( idQuery, "and" );
876+
return this.first();
878877
}
879878

880879
/**

0 commit comments

Comments
 (0)