Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 6caed7f

Browse files
author
Dekel Barzilay
committed
Added support for GROUP BY with ONLY_FULL_GROUP_BY enabled
1 parent 8f81d7e commit 6caed7f

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

test/company.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,26 @@ export default class Company extends Model {
3737
orderByName: builder => {
3838
builder.orderBy('name');
3939
},
40-
google: (builder, hasCeo) => {
40+
google: builder => {
4141
builder.where('companies.name', 'Google')
4242
.select(['companies.name'])
4343
.groupBy(['companies.name']);
44-
45-
if (hasCeo) { builder.whereNot('ceo', null); }
4644
},
47-
googleWithEager: (builder, hasCeo) => {
45+
googleWithEager: builder => {
4846
builder.where('companies.name', 'Google')
4947
.select(['companies.name'])
5048
.groupBy(['companies.name', 'companies.id']);
51-
52-
if (hasCeo) { builder.whereNot('ceo', null); }
5349
},
5450
apple: (builder, hasCeo) => {
5551
builder.where('name', 'Apple');
56-
57-
if (hasCeo) { builder.whereNot('ceo', null); }
5852
},
5953
large: (builder, hasCeo) => {
6054
builder.where('size', 'large');
6155

6256
if (hasCeo) { builder.whereNot('ceo', null); }
57+
},
58+
withRelation: builder => {
59+
builder.withGraphFetched('employees');
6360
}
6461
}
6562

test/index.test.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ describe('Feathers Objection Service', () => {
17251725
companyId: ids.companies[0].id
17261726
},
17271727
{
1728-
name: 'Apple',
1728+
name: 'Dave',
17291729
companyId: ids.companies[1].id
17301730
}
17311731
]);
@@ -1771,7 +1771,22 @@ describe('Feathers Objection Service', () => {
17711771
});
17721772
});
17731773

1774-
it('allow $modify query with paginate and groupBy and joinRelation', () => {
1774+
it('allow $modify query with paginate and eager in modifier', () => {
1775+
companies.options.paginate = {
1776+
default: 1,
1777+
max: 2
1778+
};
1779+
1780+
return companies.find({ query: { $modify: ['withRelation'], $sort: { 'companies.name': -1 } } }).then(data => {
1781+
expect(data.total).to.be.equal(2);
1782+
expect(data.data.length).to.be.equal(1);
1783+
expect(data.data[0].name).to.be.equal('Google');
1784+
expect(data.data[0].employees.length).to.be.equal(1);
1785+
expect(data.data[0].employees[0].name).to.be.equal('John');
1786+
});
1787+
});
1788+
1789+
it('allow $modify query with paginate, groupBy and joinRelation', () => {
17751790
companies.options.paginate = {
17761791
default: 1,
17771792
max: 2
@@ -1784,7 +1799,7 @@ describe('Feathers Objection Service', () => {
17841799
});
17851800
});
17861801

1787-
it.skip('allow $modify query with paginate and groupBy and eager', () => {
1802+
it.skip('allow $modify query with paginate, groupBy and eager', () => {
17881803
companies.options.paginate = {
17891804
default: 1,
17901805
max: 2

0 commit comments

Comments
 (0)