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

Commit 4d5380cc by Overlook Motel

fix problem with 'this' in validateIncludedElement

1 parent 8a832076
Showing with 4 additions and 8 deletions
...@@ -1348,7 +1348,7 @@ module.exports = (function() { ...@@ -1348,7 +1348,7 @@ module.exports = (function() {
} }
options.include = options.include.map(function(include) { options.include = options.include.map(function(include) {
include = validateIncludedElement.call(this, include, options.daoFactory, tableNames) include = validateIncludedElement.call(this, include, tableNames)
options.includeMap[include.as] = include options.includeMap[include.as] = include
options.includeNames.push(include.as) options.includeNames.push(include.as)
...@@ -1364,15 +1364,11 @@ module.exports = (function() { ...@@ -1364,15 +1364,11 @@ module.exports = (function() {
}.bind(this)) }.bind(this))
} }
var validateIncludedElement = function(include, parent, tableNames) { var validateIncludedElement = function(include, tableNames) {
if (include instanceof DAOFactory) { if (include instanceof DAOFactory) {
include = { daoFactory: include } include = { daoFactory: include }
} }
if (typeof parent === "undefined") {
parent = this
}
if (typeof include !== 'object') { if (typeof include !== 'object') {
throw new Error('Include unexpected. Element has to be either an instance of DAOFactory or an object.') throw new Error('Include unexpected. Element has to be either an instance of DAOFactory or an object.')
} }
...@@ -1405,7 +1401,7 @@ module.exports = (function() { ...@@ -1405,7 +1401,7 @@ module.exports = (function() {
if (include._pseudo) return include if (include._pseudo) return include
// check if the current daoFactory is actually associated with the passed daoFactory - or it's a pseudo include // check if the current daoFactory is actually associated with the passed daoFactory - or it's a pseudo include
var association = parent.getAssociation(include.daoFactory, include.as) var association = this.getAssociation(include.daoFactory, include.as)
if (association) { if (association) {
include.association = association include.association = association
include.as = association.as include.as = association.as
...@@ -1434,7 +1430,7 @@ module.exports = (function() { ...@@ -1434,7 +1430,7 @@ module.exports = (function() {
// Validate child includes // Validate child includes
if (include.hasOwnProperty('include')) { if (include.hasOwnProperty('include')) {
validateIncludedElements(include, tableNames) validateIncludedElements.call(include.daoFactory, include, tableNames)
} }
return include return include
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!