Skip to content

Commit

Permalink
perf(BaseGrammar): Remove the need for duplicate or structCopy calls
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Dec 11, 2018
1 parent 864c350 commit 89ea9fc
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions models/Grammars/BaseGrammar.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ component displayname="Grammar" accessors="true" {
*/
public any function runQuery( sql, bindings, options, returnObject = "query" ) {
local.result = "";
var data = structCopy( arguments );
var data = {
sql = arguments.sql,
bindings = arguments.bindings,
options = arguments.options,
returnObject = arguments.returnObject
};
tryPreInterceptor( data );
structAppend( options, { result = "local.result" }, true );
log.debug( "Executing sql: #sql#", "With bindings: #serializeJSON( bindings )#" );
var q = queryExecute( sql, bindings, options );
structAppend( data.options, { result = "local.result" }, true );
log.debug( "Executing sql: #data.sql#", "With bindings: #serializeJSON( data.bindings )#" );
var q = queryExecute( data.sql, data.bindings, data.options );
data.query = isNull( q ) ? javacast( "null", "" ) : q;
data.result = local.result;
tryPostInterceptor( data );
Expand Down Expand Up @@ -265,7 +270,8 @@ component displayname="Grammar" accessors="true" {

for ( var where in arguments.wheres ) {
var whereFunc = variables[ "where#where.type#" ];
var sql = uCase( where.combinator ) & " " & whereFunc( query, structCopy( where ) );
// TODO: needs help
var sql = uCase( where.combinator ) & " " & whereFunc( query, where );
wheresArray.append( sql );
}

Expand Down Expand Up @@ -295,15 +301,12 @@ component displayname="Grammar" accessors="true" {
return;
}

where.column = wrapColumn( where.column );

var placeholder = "?";

if ( variables.utils.isExpression( where.value ) ) {
placeholder = where.value.getSql();
}

return trim( "#where.column# #uCase( where.operator )# #placeholder#" );
return trim( "#wrapColumn( where.column )# #uCase( where.operator )# #placeholder#" );
}

/**
Expand Down

0 comments on commit 89ea9fc

Please sign in to comment.