I have an issue with a NestJs service that uses Typeorm and implements pagination logic.
When I use limit and offset on a query I execute using QueryBuilder, it does not return all results (i.e. limit 10 returns only 8 results)- it does work however, meaning that the relations aren't mapped yet still filtered on, orderby does order by a relation field without mapping it too. The issue began when I changed my limit and offset to take and skip.
It gets buggy when I use order by on a relation column I innerJoin.
For example:
querybuilder = querybuilder.innerJoin(profile.service, service)
then try to do
queryBuilder = queryBuilder.orderBy("service.price", "ASC")
It returns an error
column distinctAlias.service_price does not exist
That's because it looks like you must leftJoinAndSelect the relation in order to have the field alias included in the query.
I don't want to select the relations but only the base entity. Is there any way around it?
Limit and offset as pagination utilities are not an option since in the docs itself it says to not use them when appending joins to the query.