diff --git a/extensions/sequelize/src/__tests__/integration/repository.integration.ts b/extensions/sequelize/src/__tests__/integration/repository.integration.ts index e20bd70a480f..fc7097551abc 100644 --- a/extensions/sequelize/src/__tests__/integration/repository.integration.ts +++ b/extensions/sequelize/src/__tests__/integration/repository.integration.ts @@ -487,6 +487,23 @@ describe('Sequelize CRUD Repository (integration)', () => { expect(getResponse.body).to.be.deepEqual(reversedArray); }); + it('ignores an empty `order` filter', async () => { + const users = [ + getDummyUser({name: 'ABoy'}), + getDummyUser({name: 'BBoy'}), + getDummyUser({name: 'CBoy'}), + ]; + const createAllResponse = await client.post('/users-bulk').send(users); + const filter = { + order: '', + }; + const getResponse = await client.get(`/users`).query({ + filter, + }); + + expect(getResponse.body).to.be.deepEqual(createAllResponse.body); + }); + it('supports `limit` filter', async () => { const users = [getDummyUser(), getDummyUser(), getDummyUser()]; await client.post('/users-bulk').send(users); diff --git a/extensions/sequelize/src/sequelize/sequelize.repository.base.ts b/extensions/sequelize/src/sequelize/sequelize.repository.base.ts index ba17f80a3d40..74f8e76f1578 100644 --- a/extensions/sequelize/src/sequelize/sequelize.repository.base.ts +++ b/extensions/sequelize/src/sequelize/sequelize.repository.base.ts @@ -489,7 +489,7 @@ export class SequelizeCrudRepository< * @returns Sequelize compatible order filter value */ protected buildSequelizeOrder(order?: string[] | string): Order | undefined { - if (order === undefined) { + if (order === undefined || order === '') { return undefined; }