Skip to content

Commit

Permalink
fix(QueryBuilder): Ignore select bindings for aggregate queries
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Aug 17, 2020
1 parent b06d690 commit 8a3a181
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions models/Query/QueryBuilder.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2415,19 +2415,26 @@ component displayname="QueryBuilder" accessors="true" {
/**
* Returns a flat array of bindings. Used as the parameter list for `queryExecute`.
*
* @excpet An array of binding types to ignore
*
* @return array of bindings
*/
public array function getBindings() {
var bindingOrder = [
"commonTables",
"update",
"insert",
"select",
"join",
"where",
"orderBy",
"union"
];
public array function getBindings( array except = [] ) {
var bindingOrder = arrayFilter(
[
"commonTables",
"update",
"insert",
"select",
"join",
"where",
"orderBy",
"union"
],
function( type ) {
return !arrayContainsNoCase( except, type );
}
);

var flatBindings = [];
for ( var key in bindingOrder ) {
Expand Down Expand Up @@ -2809,7 +2816,7 @@ component displayname="QueryBuilder" accessors="true" {
structAppend( arguments.options, getDefaultOptions(), false );
var result = grammar.runQuery(
sql,
getBindings(),
getBindings( except = getAggregate().isEmpty() ? [] : [ "select" ] ),
arguments.options,
returnObject
);
Expand Down

0 comments on commit 8a3a181

Please sign in to comment.