Skip to content

in v5 the sql querybuilder's order by method type definition uses unknown instead of T #2747

Answered by rhyek
rhyek asked this question in Q&A
Discussion options

You must be logged in to vote

where is typed as where(cond: QBFilterQuery<T>, operator?: keyof typeof GroupOperator): this; and works as expected.
this snipped produces the the sql i expect:

@Entity()
export class TaskEntity {
  @PrimaryKey()
  id!: number;

  ...
}

const qb = this.tasksRepository // EntityRepository<TaskEntity>
  .createQueryBuilder()
  .where({
    id: 3 // typed correctly
  })
  .orderBy({
    id: 'ASC' // typed correctly
  } as QueryOrderMap<TaskEntity>);

that produces the following sql:

select 
  `t0`.* 
from 
  `task` as `t0` 
where 
  `t0`.`id` = 3 
order by 
  `t0`.`id` asc

The as QueryOrderMap<TaskEntity> feels out of place when compared to the where clause.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@B4nan
Comment options

@rhyek
Comment options

@B4nan
Comment options

@rhyek
Comment options

@B4nan
Comment options

Answer selected by rhyek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants