No results when using cursor and orderBy (Text type)
See original GitHub issueBug description
When using findMany I encountered a bug where the logged query from prisma returns data, yet the findMany result does not. I narrowed the bug down to using cursor+orderBy (text column) … strangely enough, when orderBy is of BigInt type, it seems to work
How to reproduce
- Clone this repo https://github.com/redeyecz/prisma-bug
- docker-compose up
- http://localhost:3000
- The shown output prints all database records in the test database, example of cursor+orderBy (bigInt), failed result of cursor+orderBy (text) and expected result
Expected behavior
I’d expect to get the data from findMany, that the database query returns
Prisma information
model Account {
id BigInt @id @default(autoincrement())
name String?
externalId String?
type String
dateInsert DateTime @default(now())
@@unique([type, externalId])
@@map("account")
}
prisma.account.findMany({
take: 3,
skip: 1,
cursor: {
id: 9 //Test3
},
orderBy: {
externalId: 'desc' // text column
}
})
Environment & setup
Node 14.16
- OS: Windows running WSL2, Docker-engine running Debian 10 (buster) based linux
- Database: Postgres 13.2 (Docker based on alpine image)
- Node.js version: v14.16.0
- Prisma version: 2.20.1
prisma : 2.20.1
@prisma/client : 2.20.1
Current platform : debian-openssl-1.1.x
Query Engine : query-engine 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine : migration-engine-cli 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 60ba6551f29b17d7d6ce479e5733c70d9c00860e (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 60ba6551f29b17d7d6ce479e5733c70d9c00860e
Studio : 0.365.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Why an cursor opened for a select with ORDER by does ...
SQL Server implicitly converts the cursor to another type if clauses in select_statement conflict with the functionality of the requested cursor ...
Read more >order by not working in implicit cursor
I have a function I'm using to pipe out rows. However the order of the result set does not change when I pass...
Read more >SQL Order by Clause overview and examples
This article will cover the SQL ORDER BY clause including syntax, usage scenarios to sort out results in a Select statement.
Read more >Sort records on text, numeric, or date values
The last-applied sort order is automatically saved with the table, query, form, or report. If you want it automatically applied the next time...
Read more >Pagination of Results | Apache Solr Reference Guide 8.7
Pagination using start and rows not only require Solr to compute (and sort) ... Cursor mark values are computed based on the sort...
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 FreeTop 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
Top GitHub Comments
Thanks for extremely detailed reproduction @redeyecz and also @hehex9
I can confirm this. We will patch this.
my minimal and reproducible example: https://github.com/hehex9/prisma-6337