The first call works correctly. Also the generated query seems to be correct but subsequent calls fetching more pages return no result.
running test 3
prisma:client Prisma Client call: +1ms
prisma:client prisma.item.findMany({
orderBy: [
{
priceNullable: "asc"
},
{
id: "asc"
}
],
cursor: {
id: "one"
},
skip: 1,
take: 1
}) +0ms
prisma:client Generated request: +0ms
prisma:client {
"modelName": "Item",
"action": "findMany",
"query": {
"arguments": {
"orderBy": [
{
"priceNullable": "asc"
},
{
"id": "asc"
}
],
"cursor": {
"id": "one"
},
"skip": 1,
"take": 1
},
"selection": {
"$composites": true,
"$scalars": true
}
}
}
+0ms
prisma:client:clientEngine sending request +0ms
prisma:client:clientEngine query plan cache miss +0ms
prisma:client:clientEngine query plan created {
"type": "dataMap",
"args": {
"expr": {
"type": "process",
"args": {
"expr": {
"type": "query",
"args": {
"type": "templateSql",
"fragments": [
{
"type": "stringChunk",
"chunk": "SELECT \"public\".\"Item\".\"id\", \"public\".\"Item\".\"priceNullable\", \"public\".\"Item\".\"price\" FROM \"public\".\"Item\" WHERE (((\"public\".\"Item\".\"priceNullable\" = (SELECT \"public\".\"Item\".\"priceNullable\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": ")) OR (SELECT \"public\".\"Item\".\"priceNullable\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": ")) IS NULL OR \"public\".\"Item\".\"priceNullable\" IS NULL) AND \"public\".\"Item\".\"id\" >= (SELECT \"public\".\"Item\".\"id\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": "))) OR ((\"public\".\"Item\".\"priceNullable\" > (SELECT \"public\".\"Item\".\"priceNullable\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": ")) OR \"public\".\"Item\".\"priceNullable\" IS NULL OR (SELECT \"public\".\"Item\".\"priceNullable\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": ")) IS NULL))) ORDER BY \"public\".\"Item\".\"priceNullable\" ASC, \"public\".\"Item\".\"id\" ASC OFFSET "
},
{
"type": "parameter"
}
],
"args": [
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
"0"
],
"argTypes": [
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "bigint",
"dbType": null
}
],
"placeholderFormat": {
"prefix": "$",
"hasNumbering": true
},
"chunkable": false
}
},
"operations": {
"pagination": {
"cursor": {
"id": {
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
}
},
"take": 1,
"skip": 1
},
"distinct": null,
"reverse": false,
"nested": {},
"linkingFields": null
}
}
},
"structure": {
"type": "object",
"serializedName": null,
"fields": {
"id": {
"type": "field",
"dbName": "id",
"fieldType": {
"arity": "required",
"type": "string"
}
},
"priceNullable": {
"type": "field",
"dbName": "priceNullable",
"fieldType": {
"arity": "optional",
"type": "float"
}
},
"price": {
"type": "field",
"dbName": "price",
"fieldType": {
"arity": "required",
"type": "float"
}
}
},
"skipNulls": false
},
"enums": {}
}
} +3ms
prisma:driver-adapter:pg [js::query_raw] '{\n' +
' "sql": "SELECT \\"public\\".\\"Item\\".\\"id\\", \\"public\\".\\"Item\\".\\"priceNullable\\", \\"public\\".\\"Item\\".\\"price\\" FROM \\"public\\".\\"Item\\" WHERE (((\\"public\\".\\"Item\\".\\"priceNullable\\" = (SELECT \\"public\\".\\"Item\\".\\"priceNullable\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($1)) OR (SELECT \\"public\\".\\"Item\\".\\"priceNullable\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($2)) IS NULL OR \\"public\\".\\"Item\\".\\"priceNullable\\" IS NULL) AND \\"public\\".\\"Item\\".\\"id\\" >= (SELECT \\"public\\".\\"Item\\".\\"id\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($3))) OR ((\\"public\\".\\"Item\\".\\"priceNullable\\" > (SELECT \\"public\\".\\"Item\\".\\"priceNullable\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($4)) OR \\"public\\".\\"Item\\".\\"priceNullable\\" IS NULL OR (SELECT \\"public\\".\\"Item\\".\\"priceNullable\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($5)) IS NULL))) ORDER BY \\"public\\".\\"Item\\".\\"priceNullable\\" ASC, \\"public\\".\\"Item\\".\\"id\\" ASC OFFSET $6",\n' +
' "args": [\n' +
' "one",\n' +
' "one",\n' +
' "one",\n' +
' "one",\n' +
' "one",\n' +
' "0"\n' +
' ],\n' +
' "argTypes": [\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "bigint",\n' +
' "dbType": null\n' +
' }\n' +
' ]\n' +
'}' +5ms
Query: SELECT "public"."Item"."id", "public"."Item"."priceNullable", "public"."Item"."price" FROM "public"."Item" WHERE ((("public"."Item"."priceNullable" = (SELECT "public"."Item"."priceNullable" FROM "public"."Item" WHERE ("public"."Item"."id") = ($1)) OR (SELECT "public"."Item"."priceNullable" FROM "public"."Item" WHERE ("public"."Item"."id") = ($2)) IS NULL OR "public"."Item"."priceNullable" IS NULL) AND "public"."Item"."id" >= (SELECT "public"."Item"."id" FROM "public"."Item" WHERE ("public"."Item"."id") = ($3))) OR (("public"."Item"."priceNullable" > (SELECT "public"."Item"."priceNullable" FROM "public"."Item" WHERE ("public"."Item"."id") = ($4)) OR "public"."Item"."priceNullable" IS NULL OR (SELECT "public"."Item"."priceNullable" FROM "public"."Item" WHERE ("public"."Item"."id") = ($5)) IS NULL))) ORDER BY "public"."Item"."priceNullable" ASC, "public"."Item"."id" ASC OFFSET $6
Params: ["one","one","one","one","one","0"]
prisma:client:clientEngine query plan executed +2ms
running test 4
prisma:client Prisma Client call: +1ms
prisma:client prisma.item.findMany({
orderBy: [
{
priceNullable: "asc"
},
{
id: "asc"
}
],
cursor: {
id: "two"
},
skip: 1,
take: 1
}) +0ms
prisma:client Generated request: +0ms
prisma:client {
"modelName": "Item",
"action": "findMany",
"query": {
"arguments": {
"orderBy": [
{
"priceNullable": "asc"
},
{
"id": "asc"
}
],
"cursor": {
"id": "two"
},
"skip": 1,
"take": 1
},
"selection": {
"$composites": true,
"$scalars": true
}
}
}
+0ms
prisma:client:clientEngine sending request +0ms
prisma:client:clientEngine query plan cache hit +0ms
prisma:client:clientEngine query plan created {
"type": "dataMap",
"args": {
"expr": {
"type": "process",
"args": {
"expr": {
"type": "query",
"args": {
"type": "templateSql",
"fragments": [
{
"type": "stringChunk",
"chunk": "SELECT \"public\".\"Item\".\"id\", \"public\".\"Item\".\"priceNullable\", \"public\".\"Item\".\"price\" FROM \"public\".\"Item\" WHERE (((\"public\".\"Item\".\"priceNullable\" = (SELECT \"public\".\"Item\".\"priceNullable\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": ")) OR (SELECT \"public\".\"Item\".\"priceNullable\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": ")) IS NULL OR \"public\".\"Item\".\"priceNullable\" IS NULL) AND \"public\".\"Item\".\"id\" >= (SELECT \"public\".\"Item\".\"id\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": "))) OR ((\"public\".\"Item\".\"priceNullable\" > (SELECT \"public\".\"Item\".\"priceNullable\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": ")) OR \"public\".\"Item\".\"priceNullable\" IS NULL OR (SELECT \"public\".\"Item\".\"priceNullable\" FROM \"public\".\"Item\" WHERE (\"public\".\"Item\".\"id\") = ("
},
{
"type": "parameter"
},
{
"type": "stringChunk",
"chunk": ")) IS NULL))) ORDER BY \"public\".\"Item\".\"priceNullable\" ASC, \"public\".\"Item\".\"id\" ASC OFFSET "
},
{
"type": "parameter"
}
],
"args": [
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
{
"prisma__type": "param",
"prisma__value": {
"name": "%1",
"type": "String"
}
},
"0"
],
"argTypes": [
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "string",
"dbType": "TEXT"
},
{
"arity": "scalar",
"scalarType": "bigint",
"dbType": null
}
],
"placeholderFormat": {
"prefix": "$",
"hasNumbering": true
},
"chunkable": false
}
},
"operations": {
"pagination": {
"cursor": {
"id": "one"
},
"take": 1,
"skip": 1
},
"distinct": null,
"reverse": false,
"nested": {},
"linkingFields": null
}
}
},
"structure": {
"type": "object",
"serializedName": null,
"fields": {
"id": {
"type": "field",
"dbName": "id",
"fieldType": {
"arity": "required",
"type": "string"
}
},
"priceNullable": {
"type": "field",
"dbName": "priceNullable",
"fieldType": {
"arity": "optional",
"type": "float"
}
},
"price": {
"type": "field",
"dbName": "price",
"fieldType": {
"arity": "required",
"type": "float"
}
}
},
"skipNulls": false
},
"enums": {}
}
} +0ms
prisma:driver-adapter:pg [js::query_raw] '{\n' +
' "sql": "SELECT \\"public\\".\\"Item\\".\\"id\\", \\"public\\".\\"Item\\".\\"priceNullable\\", \\"public\\".\\"Item\\".\\"price\\" FROM \\"public\\".\\"Item\\" WHERE (((\\"public\\".\\"Item\\".\\"priceNullable\\" = (SELECT \\"public\\".\\"Item\\".\\"priceNullable\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($1)) OR (SELECT \\"public\\".\\"Item\\".\\"priceNullable\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($2)) IS NULL OR \\"public\\".\\"Item\\".\\"priceNullable\\" IS NULL) AND \\"public\\".\\"Item\\".\\"id\\" >= (SELECT \\"public\\".\\"Item\\".\\"id\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($3))) OR ((\\"public\\".\\"Item\\".\\"priceNullable\\" > (SELECT \\"public\\".\\"Item\\".\\"priceNullable\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($4)) OR \\"public\\".\\"Item\\".\\"priceNullable\\" IS NULL OR (SELECT \\"public\\".\\"Item\\".\\"priceNullable\\" FROM \\"public\\".\\"Item\\" WHERE (\\"public\\".\\"Item\\".\\"id\\") = ($5)) IS NULL))) ORDER BY \\"public\\".\\"Item\\".\\"priceNullable\\" ASC, \\"public\\".\\"Item\\".\\"id\\" ASC OFFSET $6",\n' +
' "args": [\n' +
' "two",\n' +
' "two",\n' +
' "two",\n' +
' "two",\n' +
' "two",\n' +
' "0"\n' +
' ],\n' +
' "argTypes": [\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "string",\n' +
' "dbType": "TEXT"\n' +
' },\n' +
' {\n' +
' "arity": "scalar",\n' +
' "scalarType": "bigint",\n' +
' "dbType": null\n' +
' }\n' +
' ]\n' +
'}' +3ms
✔ 3. succeeds if cursor sits at the LOWEST price ordered by nullable field (95.70325ms)
Query: SELECT "public"."Item"."id", "public"."Item"."priceNullable", "public"."Item"."price" FROM "public"."Item" WHERE ((("public"."Item"."priceNullable" = (SELECT "public"."Item"."priceNullable" FROM "public"."Item" WHERE ("public"."Item"."id") = ($1)) OR (SELECT "public"."Item"."priceNullable" FROM "public"."Item" WHERE ("public"."Item"."id") = ($2)) IS NULL OR "public"."Item"."priceNullable" IS NULL) AND "public"."Item"."id" >= (SELECT "public"."Item"."id" FROM "public"."Item" WHERE ("public"."Item"."id") = ($3))) OR (("public"."Item"."priceNullable" > (SELECT "public"."Item"."priceNullable" FROM "public"."Item" WHERE ("public"."Item"."id") = ($4)) OR "public"."Item"."priceNullable" IS NULL OR (SELECT "public"."Item"."priceNullable" FROM "public"."Item" WHERE ("public"."Item"."id") = ($5)) IS NULL))) ORDER BY "public"."Item"."priceNullable" ASC, "public"."Item"."id" ASC OFFSET $6
Params: ["two","two","two","two","two","0"]
prisma:client:clientEngine query plan executed +1ms
✖ 4. succeeds if cursor sits at the SECOND LOWEST price ordered by nullable field (BUG) (2.550042ms)
Bug description
A
findManyquery with cursor pagination andorderByon a nullable field returns an empty array on the second call with a different cursor.The first call works correctly. Also the generated query seems to be correct but subsequent calls fetching more pages return no result.
Maybe related to the query cache or issues like those #29176 or #28614
Severity
Reproduction
Expected vs. Actual Behavior
Should return the next page (
id: "three") but returns an empty arrayFrequency
Consistently reproducible
Does this occur in development or production?
Both development and production
Is this a regression?
Yes, worked in Prisma 5.x and 7.3, broken in 7.4.1
Workaround
No acceptable workaround found
Prisma Schema & Queries
Prisma Config
Logs & Debug Info
Environment & Setup
Prisma Version