nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.04k stars 533 forks source link

Nested filters on Oracle don't work #398

Open steeu opened 4 years ago

steeu commented 4 years ago

When executing a nested filter query (https://github.com/nestjsx/crud/wiki/Requests#filter) on a oracle database i get the following error:

Error: ORA-22806: not an object or REF

The reason is the dot notation "boss.name" from the filter, that ist used in the SQL reference as "andWhereboss.name5388566708706500"

Example:

WHERE ("boss"."ENAME" = :andWhereboss.name5388566708706500) ORDER BY "EmployeeEntity"."ENAME" A
SC -- PARAMETERS: ["SCOTT"]

Unfortunately Oracle is not happy with the "." in the reference.

A possible solution, that in my case works could be to remove the "." from the reference with ${i.replace(/\./g,'')}.

See file: https://github.com/nestjsx/crud/blob/master/packages/crud-typeorm/src/typeorm-crud.service.ts Line: 531

setAndWhere(cond, i, builder) {
    const { str, params } = this.mapOperatorsToQuery(cond, `andWhere${i.replace(/\./g,'')}`);
    builder.andWhere(str, params);
}

Please let me know what you think about this.

hanza93 commented 2 years ago

I'm still having the same issue, have you found a solution @steeu ?