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

Commit 7e2c06eb by Mick Hansen

perf(query): optimize groupJoinData to use a single loop

1 parent 1c43cceb
......@@ -361,7 +361,7 @@ module.exports = (function() {
, accessor = Utils._.camelize(key)
, childOptions
, primaryKeyAttribute = include.model.primaryKeyAttribute
, isEmpty = value[0] && value[0][primaryKeyAttribute] === null
, isEmpty
if (!isEmpty) {
childOptions = {
......@@ -380,9 +380,15 @@ module.exports = (function() {
accessor = accessor.slice(0,1).toLowerCase() + accessor.slice(1)
if (association.isSingleAssociation) {
if (Array.isArray(value)) {
value = value[0];
}
isEmpty = value && value[primaryKeyAttribute] === null
accessor = Utils.singularize(accessor, self.Model.options.language)
self[accessor] = self.dataValues[accessor] = isEmpty ? null : include.model.build(value[0], childOptions)
self[accessor] = self.dataValues[accessor] = isEmpty ? null : include.model.build(value, childOptions)
} else {
isEmpty = value[0] && value[0][primaryKeyAttribute] === null
self[accessor] = self.dataValues[accessor] = isEmpty ? [] : include.model.bulkBuild(value, childOptions)
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!