不要怂,就是干,撸起袖子干!

Commit b94ee061 by Mathieu Amiot

Added table prepend option to getWhereConditions in query generator

1 parent 060b9352
Showing with 8 additions and 3 deletions
...@@ -706,7 +706,7 @@ module.exports = (function() { ...@@ -706,7 +706,7 @@ module.exports = (function() {
// Add HAVING to sub or main query // Add HAVING to sub or main query
if (options.hasOwnProperty('having')) { if (options.hasOwnProperty('having')) {
options.having = this.getWhereConditions(options.having, tableName, factory, options) options.having = this.getWhereConditions(options.having, tableName, factory, options, false)
if (subQuery) { if (subQuery) {
subQueryItems.push(" HAVING " + options.having) subQueryItems.push(" HAVING " + options.having)
} else { } else {
...@@ -813,12 +813,17 @@ module.exports = (function() { ...@@ -813,12 +813,17 @@ module.exports = (function() {
/* /*
Takes something and transforms it into values of a where condition. Takes something and transforms it into values of a where condition.
*/ */
getWhereConditions: function(smth, tableName, factory, options) { getWhereConditions: function(smth, tableName, factory, options, prepend) {
var result = null var result = null
, where = {} , where = {}
if (typeof prepend === 'undefined')
prepend = true
if (Utils.isHash(smth)) { if (Utils.isHash(smth)) {
smth = Utils.prependTableNameToHash(tableName, smth) if (!prepend)
smth = Utils.prependTableNameToHash(tableName, smth)
result = this.hashToWhereConditions(smth, factory, options) result = this.hashToWhereConditions(smth, factory, options)
} else if (typeof smth === 'number') { } else if (typeof smth === 'number') {
var primaryKeys = !!factory ? Object.keys(factory.primaryKeys) : [] var primaryKeys = !!factory ? Object.keys(factory.primaryKeys) : []
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!