TypeORM Oracle Driver,适用于query.raw但不适用于实体

时间:2018-05-25 03:59:55

标签: oracle typeorm

我可以设置TypeORM连接到Oracle Driver。使用connection.manager.query,我可以正确获取结果。

但是当我开始使用实体

const users1 = await connection.manager.findOne(USER_INFO, 80193220);

返回undefined

const users2 = await connection.manager.createQueryBuilder()
                        .select("u")
                        .from(USER_INFO, "u")
                        .where("u.uuid = :uuid", { uuid: 80193220 })
                        .getMany();

返回[]尽管在日志

中有一个打印完全查询
ctr_1  | query: SELECT USER_INFO.uuid AS USER_INFO_uuid FROM user_info USER_INFO WHERE (USER_INFO.uuid = :id_0_0) -- PARAMETERS: [80193220]
ctr_1  | createQueryBuilder:  undefined
ctr_1  | query: SELECT u.uuid AS u_uuid FROM user_info u WHERE u.uuid = :uuid -- PARAMETERS: [80193220]
ctr_1  | createQueryBuilder:  []
ctr_1  | query: SELECT u.uuid AS u_uuid FROM user_info u WHERE u.uuid = :uuid -- PARAMETERS: [80193220]
ctr_1  | Raw:  [ { U_UUID: 80193220 } ]

源代码 https://github.com/ipoppo/ctr_app

1 个答案:

答案 0 :(得分:0)

我有与此类似的问题。事实证明,在将原始结果转换为实体时,TypeORM对于名称和大小写很挑剔。

根据您的情况,尝试将const modalRef = this.modalService.open(ModalComponent); ... modalRef.result.then( (data: any) => { this.processData(data); }, (reason: any) => { }); 更改为from(USER_INFO, "u")