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

Commit 3040ed85 by Overlook Motel

Throw error where 'as' not defined

1 parent 0698669c
Showing with 5 additions and 5 deletions
...@@ -63,6 +63,11 @@ module.exports = (function() { ...@@ -63,6 +63,11 @@ module.exports = (function() {
* If self association, this is the target association - Unless we find a pairing association * If self association, this is the target association - Unless we find a pairing association
*/ */
if (this.isSelfAssociation) { if (this.isSelfAssociation) {
// check 'as' is defined for many-to-many self-association
if (this.through && this.through !== true && !this.as) {
throw new Error('\'as\' must be defined for many-to-many self-associations')
}
this.targetAssociation = this this.targetAssociation = this
} }
...@@ -118,11 +123,6 @@ module.exports = (function() { ...@@ -118,11 +123,6 @@ module.exports = (function() {
this.isAliased = true this.isAliased = true
} else { } else {
this.as = Utils.pluralize(this.target.name, this.target.options.language) this.as = Utils.pluralize(this.target.name, this.target.options.language)
if (this.isSelfAssociation && this.doubleLinked && this.as == this.targetAssociation.as) {
this.as = this.target.name + Utils.pluralize('Reverse', this.target.options.language)
this.associationAccessor = this.as
this.isAliased = true
}
} }
this.accessors = { this.accessors = {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!