【发布时间】:2019-12-14 22:08:07
【问题描述】:
当使用 TypeORM QueryBuilder() 查询数据库时,我得到:
QueryFailedError: invalid input syntax for integer: "X"
X 是存储在 DB 中的值。
最初我的实体是类型;
{type: 'decimal', precision: 5, scale: 2 }
value: number
由于我已将其更改为:
{type: 'real'}
value: string
并尝试过:
'float'
value: string
所有三种类型都会抛出相同的错误。但是,如果数据库中的值没有任何小数位 - 它工作正常。
我正在运行 Postgres v11.4、TypeORM v0.2.18 和 Nest.js v6.5.3
实体定义:
export class Entity extends BaseEntity {
@Column('float')
value: string;
}
查询:
const current = await this.entityRepo
.createQueryBuilder('uL')
.leftJoin('uL.user', 'user')
.leftJoinAndSelect('uL.currentLevel', 'cL')
.where('user.id = :id', { id: userId })
.getOne();
我希望返回实体,其值为正确的小数间距。
【问题讨论】:
标签: postgresql nestjs typeorm