Skip to content

Commit

Permalink
revert(knex): add a few more tests to verify aliases overriding
Browse files Browse the repository at this point in the history
Revers commit 4e837db
  • Loading branch information
derevnjuk committed Sep 9, 2022
1 parent d9c719a commit c19510a
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions tests/QueryBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2792,30 +2792,6 @@ describe('QueryBuilder', () => {
expect(qb.getQuery()).toEqual('delete from `author2` where `id` = ?');
});

test('override previously used aliases in select statement', async () => {
const qb = orm.em.createQueryBuilder(Publisher2, 'p').select('p.*');
qb.from(Author2, 'a');
expect(qb.getQuery()).toEqual('select `a`.* from `author2` as `a`');
});

test('override previously used aliases in where clause', async () => {
const qb = orm.em.createQueryBuilder(Publisher2, 'p').where({ 'p.id': 1 });
qb.from(Author2, 'a');
expect(qb.getQuery()).toEqual('select `a`.* from `author2` as `a` where `a`.`id` = ?');
});

test('override previously used aliases in order by clause', async () => {
const qb = orm.em.createQueryBuilder(Publisher2, 'p').orderBy({ 'p.id': 'desc' });
qb.from(Author2, 'a');
expect(qb.getQuery()).toEqual('select `a`.* from `author2` as `a` order by `a`.`id` desc');
});

test('override previously used aliases in join statement', async () => {
const qb = orm.em.createQueryBuilder(Publisher2, 'p').select(['p.*', 'b.*']).leftJoin('books', 'b');
qb.from(Author2, 'a');
expect(qb.getQuery()).toEqual('select `a`.*, `b`.* from `author2` as `a` left join `book2` as `b` on `a`.`id` = `b`.`publisher_id`');
});

test('from an entity with alias', async () => {
const qb = orm.em.createQueryBuilder(Publisher2, 'p');
qb.from(Author2, 'a');
Expand Down

0 comments on commit c19510a

Please sign in to comment.