Skip to content

Commit 7ae19c2

Browse files
authored
Update deserializer-utils.js
Ancestry check based on type and id. Resolve SeyZ#173
1 parent b0315e9 commit 7ae19c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/deserializer-utils.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = function (jsonapi, data, opts) {
3636
if (included) {
3737
// To prevent circular references, check if the record type
3838
// has already been processed in this thread
39-
if (ancestry.indexOf(included.type) > -1) {
39+
if (ancestry.find((aIncluded) => aIncluded === included.type+':'+included.id)) {
4040
return Promise
4141
.all([extractAttributes(included)])
4242
.then(function (results) {
@@ -47,7 +47,7 @@ module.exports = function (jsonapi, data, opts) {
4747
}
4848

4949
return Promise
50-
.all([extractAttributes(included), extractRelationships(included, ancestry + ':' + included.type + included.id)])
50+
.all([extractAttributes(included), extractRelationships(included, [...ancestry, included.type + ':' + included.id])])
5151
.then(function (results) {
5252
var attributes = results[0];
5353
var relationships = results[1];
@@ -146,7 +146,7 @@ module.exports = function (jsonapi, data, opts) {
146146

147147
this.perform = function () {
148148
return Promise
149-
.all([extractAttributes(data), extractRelationships(data, data.type + data.id)])
149+
.all([extractAttributes(data), extractRelationships(data, [data.type + ':' + data.id])])
150150
.then(function (results) {
151151
var attributes = results[0];
152152
var relationships = results[1];

0 commit comments

Comments
 (0)