diff --git a/lib/sql.js b/lib/sql.js index 2190cc1..aa19aa8 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -989,6 +989,8 @@ SQLConnector.prototype.buildColumnNames = function(model, filter) { * @returns {ParameterizedSQL} Statement object {sql: ..., params: [...]} */ SQLConnector.prototype.buildSelect = function(model, filter, options) { + options = options || {}; + if (!filter.order) { var idNames = this.idNames(model); if (idNames && idNames.length) { @@ -1037,6 +1039,11 @@ SQLConnector.prototype.buildSelect = function(model, filter, options) { } } + + if (options.skipParameterize === true) { + return selectStmt; + } + return this.parameterize(selectStmt); }; @@ -1062,7 +1069,9 @@ SQLConnector.prototype.buildJoins = function(model, where) { var condition = this.columnEscaped(model, keyFrom) + '=' + this.columnEscaped(modelTo, keyTo); - var innerSelect = this.buildSelect(modelTo, innerWhere); + var innerSelect = this.buildSelect(modelTo, innerWhere, { + skipParameterize: true + }); stmt .merge('INNER JOIN (')