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

Commit 0785669e by Mick Hansen

enable dao to handle nested includes

1 parent 4c7e4674
...@@ -554,7 +554,7 @@ module.exports = (function() { ...@@ -554,7 +554,7 @@ module.exports = (function() {
DAOFactory.prototype.build = function(values, options) { DAOFactory.prototype.build = function(values, options) {
options = options || { isNewRecord: true, isDirty: true } options = options || { isNewRecord: true, isDirty: true }
if (options.hasOwnProperty('include') && (!options.includeValidated || !options.includeNames)) { if (options.hasOwnProperty('include') && options.include && (!options.includeValidated || !options.includeNames)) {
options.includeNames = [] options.includeNames = []
options.include = options.include.map(function(include) { options.include = options.include.map(function(include) {
include = validateIncludedElement.call(this, include) include = validateIncludedElement.call(this, include)
......
...@@ -543,7 +543,14 @@ module.exports = (function() { ...@@ -543,7 +543,14 @@ module.exports = (function() {
accessor = accessor.slice(0,1).toLowerCase() + accessor.slice(1) accessor = accessor.slice(0,1).toLowerCase() + accessor.slice(1)
attrs[key].forEach(function(data) { attrs[key].forEach(function(data) {
var daoInstance = include.daoFactory.build(data, { isNewRecord: false, isDirty: false }) var daoInstance = include.daoFactory.build(data, {
isNewRecord: false,
isDirty: false,
include: include.include,
includeNames: include.includeNames,
includeMap: include.includeMap,
includeValidated: true
})
, isEmpty = !Utils.firstValueOfHash(daoInstance.identifiers) , isEmpty = !Utils.firstValueOfHash(daoInstance.identifiers)
if (association.isSingleAssociation) { if (association.isSingleAssociation) {
......
...@@ -53,12 +53,10 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -53,12 +53,10 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]} ]}
] ]
}).done(function (err, task) { }).done(function (err, task) {
console.log(err && err.sql)
expect(err).not.to.be.ok expect(err).not.to.be.ok
expect(task.user).to.be.ok expect(task.user).to.be.ok
expect(task.user.group).to.be.ok expect(task.user.group).to.be.ok
}).on('sql', function (sql) { done()
console.log(sql)
}) })
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!