Trouble using subquery in left joins without using getRawMany
See original GitHub issueIssue type:
[X] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[X] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[ ] @next
[X] 0.2.16
(or put your version here)
Steps to reproduce or a small repository showing the problem: I’m trying to add pagination to left joins using subqueries but I can’t figure it out how to do it properly, or if it can be done at all.
qb.leftJoinAndSelect(
subq =>
subq
.select()
.from(Centres, 'centres')
.take(1),
'centres',
'centres.deleted = :deleted',
{ deleted: false },
);
return await qb.getMany();
This is my code so far and with that I do not get the relation injected into my user object. It works fine if I execute the query with getRawMany() but it won’t work with the format i’m trying to get.
Any ideas how to solve this or with any other way to paginate the relations in my queries?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (1 by maintainers)
Got the same issue when using a subquery, or a select statement.
So it seems when you do a subquery or a select stament like so:
The Raw data is correct:
But as you can see, the entity is empty. It does not matter how i format or name the selectable columns or how i format or name the entity properties. It does not map to an entity when you use a subquery or a select statement.
This is how the entities look like at my end:
I have been searching for this issue for two days and have seen that anyone with this issue has not got any answers. @CesarHuelamo is no exception to this fact.
related issues:
related comment:
The example he is given, where he states that it should map, it does not map.
The answer given by @pleerock:
“Shall work” but it does not work.
Please clarify this. Is this a bug or is this intended. And when it is intended, the docs are wrong too.
When I use this exact code, the getMany() returns no results. On the other hand, the getRawMany(); returns results.
@xxzefgh Sorry if I made it sound like you were saying that it worked. My intention was to make it very clear for the typeorm team that it does not work. Because that particular question/bug has never been answered. Thank you for replying.