Skip to content

Commit

Permalink
test: add test that uses CTE (Common table expressions)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Apr 26, 2023
1 parent 3637e6d commit d67d360
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,18 @@ describe('paginate', () => {
expect(logStr).not.toContain('order by');
});

it('should support CTE (Common table expressions) statements', async () => {
const result = await db
.with('with_alias', (qb) => qb.select('*').from('persons').where('persons.id', 2))
.select('*')
.from('with_alias')
.paginate({
currentPage: 1,
perPage: 2,
});
expect(result.pagination.total).toEqual(1);
});

describe('grouping', () => {
it('should count total as distinct column when group is provided', async () => {
const result = await db('persons')
Expand Down

0 comments on commit d67d360

Please sign in to comment.