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

Commit 8f81d7e

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

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

test/company.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ export default class Company extends Model {
4444

4545
if (hasCeo) { builder.whereNot('ceo', null); }
4646
},
47+
googleWithEager: (builder, hasCeo) => {
48+
builder.where('companies.name', 'Google')
49+
.select(['companies.name'])
50+
.groupBy(['companies.name', 'companies.id']);
51+
52+
if (hasCeo) { builder.whereNot('ceo', null); }
53+
},
4754
apple: (builder, hasCeo) => {
4855
builder.where('name', 'Apple');
4956

test/index.test.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function clean (done) {
248248
return db.schema
249249
.createTable('employees', table => {
250250
table.increments('id');
251-
table.integer('companyId').references('companies.id');
251+
table.integer('companyId');
252252
table.string('name');
253253
});
254254
});
@@ -258,7 +258,7 @@ function clean (done) {
258258
return db.schema
259259
.createTable('clients', table => {
260260
table.increments('id');
261-
table.integer('companyId').references('companies.id');
261+
table.integer('companyId');
262262
table.string('name');
263263
})
264264
.then(() => done());
@@ -1771,7 +1771,7 @@ describe('Feathers Objection Service', () => {
17711771
});
17721772
});
17731773

1774-
it('allow $modify query with paginate and groupBy', () => {
1774+
it('allow $modify query with paginate and groupBy and joinRelation', () => {
17751775
companies.options.paginate = {
17761776
default: 1,
17771777
max: 2
@@ -1784,6 +1784,19 @@ describe('Feathers Objection Service', () => {
17841784
});
17851785
});
17861786

1787+
it.skip('allow $modify query with paginate and groupBy and eager', () => {
1788+
companies.options.paginate = {
1789+
default: 1,
1790+
max: 2
1791+
};
1792+
1793+
return companies.find({ query: { $modify: ['googleWithEager'], $eager: 'employees' } }).then(data => {
1794+
expect(data.total).to.be.equal(1);
1795+
expect(data.data.length).to.be.equal(1);
1796+
expect(data.data[0].name).to.be.equal('Google');
1797+
});
1798+
});
1799+
17871800
it('allow $modify query as string', () => {
17881801
return companies.find({ query: { $modify: 'google' } }).then(data => {
17891802
expect(data.length).to.be.equal(1);

0 commit comments

Comments
 (0)