Skip to content
Browse files
fix(QueryBuilder): Prefer the parent query over magic methods
If a parent query has been set, and a missing method is
found on the parent query, then call it before trying the
magic `where` methods.  This does not change the final try
to the parent query if no methods match.  That is still attempted
which allows the parent query to try `onMissingMethod` magic.
  • Loading branch information
elpete committed Feb 28, 2020
1 parent 3049de2 commit f9fd8d157cdc0d7480811c4659c130ee1d58888f
Showing 1 changed file with 9 additions and 0 deletions.
@@ -2559,6 +2559,15 @@ component displayname="QueryBuilder" accessors="true" {
* @return any
public any function onMissingMethod( string missingMethodName, struct missingMethodArguments ) {
* If a parent query has been set, and has this exact method name,
* forward on the method call to the parent query.
if ( !isNull( variables.parentQuery ) && structKeyExists( variables.parentQuery, missingMethodName ) ) {
return invoke( variables.parentQuery.populateQuery( this ), missingMethodName, missingMethodArguments );

* This block handles dynamic `andWhere` methods.
* If the method exists without the `and` we route the call there.

0 comments on commit f9fd8d1

Please sign in to comment.