fix: append belongs to association with fields (#1894)
This commit is contained in:
parent
ccdc05b30b
commit
aabc681245
@ -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', () => {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user