Skip to content

Commit 199098e

Browse files
committed
added broken test case to sort by virtualcolumn. fails in pgsql
1 parent 2b717aa commit 199098e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/paginate.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
parseFilterToken,
2323
} from './filter'
2424
import { paginate, PaginateConfig, Paginated, PaginationLimit, PaginationType } from './paginate'
25+
import 'dotenv/config'
2526

2627
// Disable debug logs during tests
2728
beforeAll(() => {
@@ -686,6 +687,22 @@ describe('paginate', () => {
686687
expect(result.data).toStrictEqual([cats[3], cats[4], cats[1], cats[0], cats[2]])
687688
})
688689

690+
it('should sort result by virtual columns', async () => {
691+
const config: PaginateConfig<CatEntity> = {
692+
sortableColumns: ['home.countCat'],
693+
relations: ['home'],
694+
}
695+
const query: PaginateQuery = {
696+
path: '',
697+
sortBy: [['home.countCat', 'DESC']],
698+
}
699+
700+
const result = await paginate<CatEntity>(query, catRepo, config)
701+
702+
expect(result.meta.sortBy).toStrictEqual([['home.countCat', 'DESC']])
703+
expect(result.data).toStrictEqual([cats[3], cats[4], cats[1], cats[0], cats[2]])
704+
})
705+
689706
it('should sort result by camelcase columns', async () => {
690707
const config: PaginateConfig<CatEntity> = {
691708
sortableColumns: ['cutenessLevel', 'name'],

0 commit comments

Comments
 (0)