Wrong totalCount when using joins in QB
See original GitHub issueIn this commit https://github.com/nestjsx/nestjs-typeorm-paginate/commit/890ee164e15a1495782917b8443f0cd4cca0b7c0#diff-c58e144dadf00250381ed55e6ce83245cda76aca84131ad494fd4911932f656f. a custom total count query was introduced instead of TypeORMs qb.getCount()
;
this query being SELECT COUNT(*) FROM (…) returns number of all rows returned by query which would be like (m*n* k…) depending on how many rows were joined
the original implementation of TypeORMs getCount does SELECT COUNT(DISTINCT("table"."id")) AS "cnt" FROM (..)
which returns correct number of entities even when using JOINs
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:27 (4 by maintainers)
Top Results From Across the Web
Query operations and syntax - Intuit Developer
To find out how many entities will be returned by a query, specify the COUNT keyword. The number of entities is returned as...
Read more >Error converting value "Bounced Email" to type ... - GitHub
Invoice object, I am encountering the following error for some invoices: Error converting value "Bounced Email" to type 'Intuit.Ipp.Data.
Read more >Count Rows in Doctrine QueryBuilder - symfony - Stack Overflow
Example working with grouping, union and stuff. Problem: $qb = $em->createQueryBuilder() ->select('m.id', 'rm.id') ->from('Model', 'm') ->join('m.
Read more >NFL Insider Weighs In on the Complexities the Packers Deal ...
Jordan Love, the 2020 first-round pick QB of the Packers stares at his third ... 5 lunges alternative exercises for people with bad...
Read more >NFL Insider Weighs In on the Complexities the Packers Deal ...
Jordan Love, the 2020 first-round pick QB of the Packers stares at ... However, Rodgers himself had to deal with it while competing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My solution with this problem, was return the function
metaTransformer
and modifying the return oftotalItems
andtotalPages
.I know it’s not right this way, but was that I found at moment.
@ayeen, thank you for your advice.
I know about this option and used it. But in my case the result was not completely correct. When I set
paginationType: PaginationTypeEnum.TAKE_AND_SKIP
, I’ve got the correct value (count) ofitems
, butmeta.totalItems
was incorrect. For example,items
is an array of 5 elements (which is true), butmeta.totalItems
is 10.