diff --git a/packages/core/database/src/__tests__/repository/find.test.ts b/packages/core/database/src/__tests__/repository/find.test.ts index 310b88376..7f5520f94 100644 --- a/packages/core/database/src/__tests__/repository/find.test.ts +++ b/packages/core/database/src/__tests__/repository/find.test.ts @@ -440,6 +440,15 @@ describe('repository find', () => { expect(Object.keys(data)).toEqual(['id', 'posts']); expect(Object.keys(data['posts'])).not.toContain('id'); }); + + test('find one with appends', async () => { + const profile = await Profile.repository.findOne({ + filterByTk: 1, + appends: ['user.name'], + }); + + expect(profile.get('user').get('name')).toEqual('u1'); + }); }); describe('find', () => { diff --git a/packages/core/database/src/eager-loading/eager-loading-tree.ts b/packages/core/database/src/eager-loading/eager-loading-tree.ts index 496dd9681..a2182d136 100644 --- a/packages/core/database/src/eager-loading/eager-loading-tree.ts +++ b/packages/core/database/src/eager-loading/eager-loading-tree.ts @@ -76,10 +76,10 @@ export class EagerLoadingTree { } if (associationType == 'BelongsTo') { - const { sourceKey, foreignKey } = association; + const { targetKey, foreignKey } = association; pushAttribute(eagerLoadingTreeParent, foreignKey); - pushAttribute(child, sourceKey); + pushAttribute(child, targetKey); } eagerLoadingTreeParent.children.push(child);