model: fix infinite loop on nestRemoting
Prevent endless recursion on nestRemoting calls for two-way model links.
This commit is contained in:
parent
d23ff84587
commit
386615a1df
|
@ -873,7 +873,10 @@ module.exports = function(registry) {
|
|||
|
||||
var regExp = /^__([^_]+)__([^_]+)$/;
|
||||
var relation = this.relations[relationName];
|
||||
if (relation && relation.modelTo && relation.modelTo.sharedClass) {
|
||||
if (relation && relation._nestRemotingProcessed) {
|
||||
return; // Prevent unwanted circular traversals!
|
||||
} else if (relation && relation.modelTo && relation.modelTo.sharedClass) {
|
||||
relation._nestRemotingProcessed = true;
|
||||
var self = this;
|
||||
var sharedClass = this.sharedClass;
|
||||
var sharedToClass = relation.modelTo.sharedClass;
|
||||
|
|
|
@ -1480,6 +1480,7 @@ describe('relations - integration', function() {
|
|||
Book.hasMany(Page, {options: {nestRemoting: true}});
|
||||
Book.hasMany(Chapter);
|
||||
Page.hasMany(Note);
|
||||
Page.belongsTo(Book, {options: {nestRemoting: true}});
|
||||
Chapter.hasMany(Note);
|
||||
Image.belongsTo(Book);
|
||||
|
||||
|
|
Loading…
Reference in New Issue