Repository navigation
Description
Bug description
< This is my latest bug report >
I am currently using the preview version of 'Order By Relations'.
There is a bug that ignores the same value (when count value is 0).
When I order(sort) by the number of people who press like,
if the value is zero(ex: A => likeCountPerson:0 , B=> likeCountPerson:0), prisma ignores it.
DataModel seems like this.
model Post {
likeCountPeople Person[]
}
model Person {
}client.post.findMany ({
// ...
orderBy: {
likeCountPeople: { _count: "desc" },
}
})< I found why it doesn't work well i expected >
When I tried to move it again, there was no problem with that part.
But when i get order by the number of people who press like with cursorId,
prisma ignores it. OrderBy Relation with CursorId ignores " _count value is zero" is the key.
When I order By likeCountPeople _count "desc" with no CursorId,
5 Data comes out ( Including having zero data )
"data": {
[
"post1":
{
"id": 1,
"likeCountPeople" : {
<Person 1>,
<Person 2>,
<Person 3>
}
},
"post2":
{
"id": 2,
"likeCountPeople" : {
<Person 1>,
<Person 2>,
}
},
"post3":
{
"id": 3,
"likeCountPeople" : {
<Person 1>,
}
},
"post4":
{
"id": 4,
"likeCountPeople" : {
NO PERSON
}
},
"post5":
{
"id": 5,
"likeCountPeople" : {
NO PERSON
}
},
]
}
But , When I order By likeCountPeople _count "desc" with CursorId, Prisma ignores if _count value is zero.
...(cursorBakeryId && { cursor: { id: 1} }),
skip: cursorId ? 1 : 0,
take: 5,
orderBy: {
likeCountPeople: { _count: "desc" },
},
2 Data comes out ( It should be to have four data except for one data that be skipped )
But the data that _count == 0 (count value is zero) is ignored .
"data": {
[
"post2":
{
"id": 2,
"likeCountPeople" : {
<Person 1>,
<Person 2>,
}
},
"post3":
{
"id": 3,
"likeCountPeople" : {
<Person 1>,
}
},
]
}
How to reproduce
Expected behavior
When I orderBy Relation with cursorId, output data should be include if _count value is zero.
Of course, it goes well if i don't use cursorId.
Prisma information
Environment & setup
- OS: Window 10 Pro
- Dataase: PostgreSQL,
- Node.js version: v12.16.3
Prisma Version
prisma : 2.24.1
@prisma/client : 2.24.1
Current platform : windows
Activity
matthewmueller commentedon Jul 6, 2021
Can you share a reproduction script?
pantharshit00 commentedon Jul 6, 2021
@ehdrms785 Can you please also try this with latest version
2.26? Also, as Matt mentioned, please try to share a isolated reproduction. The above setup with take lot of manual setup in order for us to reproduce a problem.Here is an example reproduction: https://github.com/harshit-test-org/prisma-issue-7007
ehdrms785 commentedon Jul 6, 2021
@pantharshit00
I tried version 2.26, but it was same result.
Here is the reproduction script :) I don't know I did well but I tried.
If it was something wrong please let me know.
https://github.com/ehdrms785/prisma-issue-8036
pantharshit00 commentedon Jul 12, 2021
Thanks for the reproduction repo, I can confirm this bug using that.
Candidating this.
[-]Order By Relation with CursorId[/-][+]Order By Relation with CursorId doesn't return result[/+]