Skip to content

Commit cef73c4

Browse files
committed
cleanup
1 parent d8ca98a commit cef73c4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/relations/RelationOwner.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ class RelationOwner {
7171
if (values) {
7272
builder.whereInComposite(relatedRefs, values);
7373
} else {
74-
builder.where(false);
75-
builder.resolve([]);
74+
builder.where(false).resolve([]);
7675
}
7776
} else {
78-
builder.where(false);
79-
builder.resolve([]);
77+
builder.where(false).resolve([]);
8078
}
8179

8280
return builder;

tests/integration/find.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,16 +2400,21 @@ module.exports = (session) => {
24002400
});
24012401
});
24022402

2403-
it('should return undefined if the model has no parents', async () => {
2403+
it('should return undefined if the result is empty', async () => {
24042404
const parent = await Model1.query().findById(2);
24052405

24062406
const result1 = await parent.$relatedQuery('model1Relation1');
24072407
expect(result1).to.be.equal(undefined);
24082408

2409-
const result2 = await Model1.relatedQuery('model1Relation1').for(
2410-
Model1.relatedQuery('model1Relation1').for(parent)
2409+
const result2 = await Model1.query().from(
2410+
Model1.relatedQuery('model1Relation1').for(parent).as('model1')
24112411
);
24122412
expect(result2).to.eql([]);
2413+
2414+
const result3 = await Model1.query().from(
2415+
Model1.relatedQuery('model1Relation1').for(parent.id).as('model1')
2416+
);
2417+
expect(result3).to.eql([]);
24132418
});
24142419

24152420
describe('knex methods', () => {

0 commit comments

Comments
 (0)