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

Commit f711d1ec by Daniel Durante

Forgot to add special whereCondition fix for postgres as well.

1 parent ad9ff463
Showing with 14 additions and 6 deletions
...@@ -483,18 +483,26 @@ module.exports = (function() { ...@@ -483,18 +483,26 @@ module.exports = (function() {
}) })
}, },
getWhereConditions: function(smth, tableName) { getWhereConditions: function(smth, tableName, factory) {
var result = null var result = null
, where = {}
if (Utils.isHash(smth)) { if (Utils.isHash(smth)) {
smth = Utils.prependTableNameToHash(tableName, smth) smth = Utils.prependTableNameToHash(tableName, smth)
result = this.hashToWhereConditions(smth) result = this.hashToWhereConditions(smth)
} } else if (typeof smth === 'number') {
else if (typeof smth === "number") { var primaryKeys = !!factory ? Object.keys(factory.primaryKeys) : []
smth = Utils.prependTableNameToHash(tableName, { id: smth }) if (primaryKeys.length > 0) {
// Since we're just a number, assume only the first key
primaryKeys = primaryKeys[0]
} else {
primaryKeys = 'id'
}
where[primaryKeys] = smth
smth = Utils.prependTableNameToHash(tableName, where)
result = this.hashToWhereConditions(smth) result = this.hashToWhereConditions(smth)
} } else if (typeof smth === "string") {
else if (typeof smth === "string") {
result = smth result = smth
} }
else if (Array.isArray(smth)) { else if (Array.isArray(smth)) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!