@@ -6,6 +6,9 @@ var _extend = require('lodash/extend');
6
6
var _transform = require ( 'lodash/transform' ) ;
7
7
var Inflector = require ( './inflector' ) ;
8
8
9
+ const ancestrySeparator = ":" ;
10
+ const idSeparator = ";" ;
11
+
9
12
module . exports = function ( jsonapi , data , opts ) {
10
13
var alreadyIncluded = [ ] ;
11
14
@@ -36,7 +39,7 @@ module.exports = function (jsonapi, data, opts) {
36
39
if ( included ) {
37
40
// To prevent circular references, check if the record type
38
41
// has already been processed in this thread
39
- if ( ancestry . indexOf ( included . type ) > - 1 ) {
42
+ if ( ancestry . indexOf ( included . type + idSeparator ) > - 1 ) {
40
43
return Promise
41
44
. all ( [ extractAttributes ( included ) ] )
42
45
. then ( function ( results ) {
@@ -47,7 +50,7 @@ module.exports = function (jsonapi, data, opts) {
47
50
}
48
51
49
52
return Promise
50
- . all ( [ extractAttributes ( included ) , extractRelationships ( included , ancestry + ':' + included . type + included . id ) ] )
53
+ . all ( [ extractAttributes ( included ) , extractRelationships ( included , ancestry + ancestrySeparator + included . type + idSeparator + included . id ) ] )
51
54
. then ( function ( results ) {
52
55
var attributes = results [ 0 ] ;
53
56
var relationships = results [ 1 ] ;
@@ -146,7 +149,7 @@ module.exports = function (jsonapi, data, opts) {
146
149
147
150
this . perform = function ( ) {
148
151
return Promise
149
- . all ( [ extractAttributes ( data ) , extractRelationships ( data , data . type + data . id ) ] )
152
+ . all ( [ extractAttributes ( data ) , extractRelationships ( data , data . type + ancestrySeparator + data . id ) ] )
150
153
. then ( function ( results ) {
151
154
var attributes = results [ 0 ] ;
152
155
var relationships = results [ 1 ] ;
0 commit comments