-
in v5 the sql querybuilder's order by method's param is typed as Should it not be |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
QB is not really type safe, as you often want to use aliased property names and that can't be type checked (nowadays maybe with string literal types, but seems like a bit unreal task to accomplish tbh). If we do that, it would force usage of |
Beta Was this translation helpful? Give feedback.
-
where is typed as @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 |
Beta Was this translation helpful? Give feedback.
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:
that produces the following sql:
The
as QueryOrderMap<TaskEntity>
feels out of place when compared to the where clause.