-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error Thrown When Sorting Field Is Not Selected #24152
Comments
Hey @Hellio404, I can confirm the ""2100 parameters"" error message but I can't confirm the resolution by including the await prisma.post.findMany({
where: { authorId: { in: Array.from(Array(4000).keys()) } },
- select: { id: true, title: true },
+ select: { id: true, title: true, createdAt: true },
orderBy: { createdAt: 'asc' },
}); Could you please provide a reproduction that shows this succeeding with the inclusion of |
I double checked and I confirm that adding the const { id } = await client.user.create({
data: {
posts: {
createMany: {
data: Array(4000).fill({title: 'post'}),
}
}
}
});
// this works
const sortedPosts = await client.post.findMany({
where: { authorId: { in: Array.from(Array(4000).keys()) }},
select: {id: true, title: true, createdAt: true},
orderBy: {createdAt: 'asc'},
});
// this works too
await client.post.findMany({
where: { authorId: { in: Array.from(Array(4000).keys()) }},
orderBy: {createdAt: 'asc'},
}); |
Huh, I double checked in another repro repo and I can reproduce it there. You can see a link above. For some reason, however, I still cannot reproduce this in our internal reproductions dir that directly hooks into a locally-built version of the client. I have no idea what's going on there :/ Looking at the succeeding findMany query that includes SELECT [dbo].[Post].[id], [dbo].[Post].[title], [dbo].[Post].[createdAt]
FROM [dbo].[Post]
WHERE [dbo].[Post].[authorId] IN (@P1 ... @P2098)
SELECT [dbo].[Post].[id], [dbo].[Post].[title], [dbo].[Post].[createdAt]
FROM [dbo].[Post]
WHERE [dbo].[Post].[authorId] IN (@P1 ... @P1902) If I swap to the failing query that doesn't include SELECT [dbo].[Post].[id], [dbo].[Post].[title]
FROM [dbo].[Post]
WHERE [dbo].[Post].[authorId] IN (@P1 ... @P2098) with the following error:
This is the relevant code that it references and then the following SQL query after: SELECT [dbo].[Post].[id], [dbo].[Post].[title]
FROM [dbo].[Post]
WHERE [dbo].[Post].[authorId] IN (@P1 ... @P1902) |
Do I interpret this correctly @Druue, that a chunked query for SQL Server is not including the |
Hi Prisma Team! My Prisma Client just crashed. This is the report:
Versions
Logs
Client Snippet
Schema
Description
I've noticed that whenever a query is split (due to the maximum parameter constraint of 2100 in SQL Server), Prisma attempts to perform an in-memory sort.
However, if the field being sorted is not selected, an error is thrown.
To fix this issue, I had to always include the field used for sorting in the selected fields.
The text was updated successfully, but these errors were encountered: