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

Commit a4dd202c by Mick Hansen

forgot dao-factory file

1 parent 4dfd3298
Showing with 16 additions and 2 deletions
...@@ -1194,17 +1194,25 @@ module.exports = (function() { ...@@ -1194,17 +1194,25 @@ module.exports = (function() {
}.bind(this)) }.bind(this))
} }
var validateIncludedElement = function(include) { var validateIncludedElement = function(include, parent) {
if (include instanceof DAOFactory) { if (include instanceof DAOFactory) {
include = { daoFactory: include, as: include.tableName } include = { daoFactory: include, as: include.tableName }
} }
if (typeof parent === "undefined") {
parent = this
}
if (typeof include === 'object') { if (typeof include === 'object') {
if (include.hasOwnProperty('model')) { if (include.hasOwnProperty('model')) {
include.daoFactory = include.model include.daoFactory = include.model
delete include.model delete include.model
} }
if (!include.hasOwnProperty('as')) {
include.as = include.daoFactory.tableName
}
if (include.hasOwnProperty('attributes')) { if (include.hasOwnProperty('attributes')) {
var primaryKeys; var primaryKeys;
if (include.daoFactory.hasPrimaryKeys) { if (include.daoFactory.hasPrimaryKeys) {
...@@ -1222,7 +1230,7 @@ module.exports = (function() { ...@@ -1222,7 +1230,7 @@ module.exports = (function() {
if (include.hasOwnProperty('daoFactory') && (include.hasOwnProperty('as'))) { if (include.hasOwnProperty('daoFactory') && (include.hasOwnProperty('as'))) {
var usesAlias = (include.as !== include.daoFactory.tableName) var usesAlias = (include.as !== include.daoFactory.tableName)
, association = (usesAlias ? this.getAssociationByAlias(include.as) : this.getAssociation(include.daoFactory)) , association = (usesAlias ? parent.getAssociationByAlias(include.as) : parent.getAssociation(include.daoFactory))
// If single (1:1) association, we singularize the alias, so it will match the automatically generated alias of belongsTo/HasOne // If single (1:1) association, we singularize the alias, so it will match the automatically generated alias of belongsTo/HasOne
if (association && !usesAlias && association.isSingleAssociation) { if (association && !usesAlias && association.isSingleAssociation) {
...@@ -1233,6 +1241,12 @@ module.exports = (function() { ...@@ -1233,6 +1241,12 @@ module.exports = (function() {
if (!!association && (!association.options.as || (association.options.as === include.as))) { if (!!association && (!association.options.as || (association.options.as === include.as))) {
include.association = association include.association = association
if (include.hasOwnProperty('include')) {
include.include = include.include.map(function(childInclude) {
return validateIncludedElement.call(this, childInclude, include.daoFactory)
}.bind(this))
}
return include return include
} else { } else {
var msg = include.daoFactory.name var msg = include.daoFactory.name
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!