one-to-many and many-to-one filtering by non id field doesn't work
Closed this issue · 2 comments
vsamofal commented
I created 2 unit tests that showed that where by not id field doesn't work
the error is
`
Error: Cannot query across one-to-many for property toys
at SelectQueryBuilder.createPropertyPath (/Users/vsamofal/projects/nestjs/nestjs-paginate/src/query-builder/QueryBuilder.ts:1404:27)
at SelectQueryBuilder.getPredicates (/Users/vsamofal/projects/nestjs/nestjs-paginate/src/query-builder/QueryBuilder.ts:1447:40)
at getPredicates.next (<anonymous>)
at SelectQueryBuilder.getWhereCondition (/Users/vsamofal/projects/nestjs/nestjs-paginate/src/query-builder/QueryBuilder.ts:1621:50)
at SelectQueryBuilder.andWhere (/Users/vsamofal/projects/nestjs/nestjs-paginate/src/query-builder/SelectQueryBuilder.ts:1183:29)
at Brackets.whereFactory (/Users/vsamofal/projects/nestjs/nestjs-paginate/src/paginate.ts:203:55)
at
`
the error is in paginate.ts line 203.
I can fix it by myself, but would appreciate some input from creators on this
For some reason, the query builder is rejecting this
vsamofal commented
I think I know what is the problem and going to try to fix it, it's because of ObjectLiteral usage for andWhere, it doesn't work properly in typeorm unfortunately, they even don't have any examples in docs on how it should work with an object