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

Commit 882d8492 by Mick Hansen

fix tests

1 parent 6d2295ff
Showing with 14 additions and 2 deletions
......@@ -149,6 +149,16 @@ module.exports = (function() {
, values = []
, key
, value
, modelAttributeMap = {}
if (modelAttributes) {
Utils._.each(modelAttributes, function (attribute, key) {
modelAttributeMap[key] = attribute;
if (attribute.field) {
modelAttributeMap[attribute.field] = attribute;
}
});
}
if (this._dialect.supports['DEFAULT VALUES']) {
emptyQuery += " DEFAULT VALUES"
......@@ -169,14 +179,14 @@ module.exports = (function() {
fields.push(this.quoteIdentifier(key))
// SERIALS' can't be NULL in postgresql, use DEFAULT where supported
if (modelAttributes && modelAttributes[key] && modelAttributes[key].autoIncrement === true && !value) {
if (modelAttributeMap && modelAttributeMap[key] && modelAttributeMap[key].autoIncrement === true && !value) {
if (this._dialect.supports['DEFAULT']) {
values.push('DEFAULT')
} else {
values.push(this.escape(null))
}
} else {
values.push(this.escape(value, (modelAttributes && modelAttributes[key]) || undefined))
values.push(this.escape(value, (modelAttributeMap && modelAttributeMap[key]) || undefined))
}
}
}
......@@ -640,8 +650,10 @@ module.exports = (function() {
attr[0] = attr[0].toString(self)
addTable = false
} else {
if (attr[0].indexOf('(') === -1 && attr[0].indexOf(')') === -1) {
attr[0] = this.quoteIdentifier(attr[0])
}
}
attr = [attr[0], this.quoteIdentifier(attr[1])].join(' as ')
} else {
attr = attr.indexOf(Utils.TICK_CHAR) < 0 && attr.indexOf('"') < 0 ? this.quoteIdentifiers(attr) : attr
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!