@@ -8,6 +8,7 @@ import { entities as fiveEntities } from '../test-utils/five/entities';
8
8
import { entities as sixEntities } from '../test-utils/six/entities' ;
9
9
import { entities as twelveEntities } from '../test-utils/twelve/entities' ;
10
10
import { entities as thirteenEntities } from '../test-utils/thirteen/entities' ;
11
+ import { entities as fourteenEntities } from '../test-utils/fourteen/entities' ;
11
12
import { Articles } from '../test-utils/blog/models/article' ;
12
13
const two = require ( '../test-utils/two/results' ) ;
13
14
const three = require ( '../test-utils/three/results' ) ;
@@ -22,6 +23,7 @@ const ten = require('../test-utils/ten/results.json');
22
23
const eleven = require ( '../test-utils/eleven/results.json' ) ;
23
24
const twelve = require ( '../test-utils/twelve/results.json' ) ;
24
25
const thirteen = require ( '../test-utils/thirteen/results.json' ) ;
26
+ const fourteen = require ( '../test-utils/fourteen/results.json' ) ;
25
27
26
28
describe ( 'createFromDatabase' , ( ) => {
27
29
test ( 'multiple rows reduce to one nested object (with all one-to-one or one-to-many tables)' , ( ) => {
@@ -1066,6 +1068,19 @@ describe('createFromDatabase', () => {
1066
1068
. audience . id
1067
1069
) . toEqual ( 1 ) ;
1068
1070
} ) ;
1071
+
1072
+ // Issue occcurs in nestClump
1073
+ // Problem when a table has two columns which reference the same other table
1074
+ test ( '14' , ( ) => {
1075
+ const core = createCore ( { entities : fourteenEntities } ) ;
1076
+ const persons = core . createFromDatabase ( fourteen ) ;
1077
+ expect ( persons ?. models . length ) . toEqual ( 1 ) ;
1078
+ expect ( persons . models [ 0 ] . id ) . toEqual ( 67 ) ;
1079
+ // Known issue: A reference always uses the model's name,
1080
+ // instead of some version of the column's name
1081
+ expect ( persons . models [ 0 ] . customers ?. models . length ) . toEqual ( 1 ) ;
1082
+ expect ( persons . models [ 0 ] . customers . models [ 0 ] . id ) . toEqual ( 4 ) ;
1083
+ } ) ;
1069
1084
} ) ;
1070
1085
1071
1086
describe ( 'createOneFromDatabase' , ( ) => {
0 commit comments