-
Notifications
You must be signed in to change notification settings - Fork 2.5k
LocalAPI: paginated query with a filter on a date field inside an array field does not retrieve all docs of the queried page #12263
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
Labels
Comments
DanRibbens
pushed a commit
that referenced
this issue
May 12, 2025
…ying with nested fields or relations (#12365) Fixes #12263 This was caused by passing not needed columns to the `SELECT DISTINCT` query, which we execute in case if we have a filter / sort by a nested field / relationship. Since the only columns that we need to pass to the `SELECT DISTINCT` query are: ID and field(s) specified in `sort`, we now filter the `selectFields` variable.
kendelljoseph
pushed a commit
that referenced
this issue
May 15, 2025
…ying with nested fields or relations (#12365) Fixes #12263 This was caused by passing not needed columns to the `SELECT DISTINCT` query, which we execute in case if we have a filter / sort by a nested field / relationship. Since the only columns that we need to pass to the `SELECT DISTINCT` query are: ID and field(s) specified in `sort`, we now filter the `selectFields` variable.
🚀 This is included in version v3.38.0 |
kendelljoseph
pushed a commit
that referenced
this issue
May 19, 2025
…ying with nested fields or relations (#12365) Fixes #12263 This was caused by passing not needed columns to the `SELECT DISTINCT` query, which we execute in case if we have a filter / sort by a nested field / relationship. Since the only columns that we need to pass to the `SELECT DISTINCT` query are: ID and field(s) specified in `sort`, we now filter the `selectFields` variable.
This issue has been automatically locked. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Uh oh!
There was an error while loading. Please reload this page.
Describe the Bug
Trying to query a paginated list of docs with a filter on a date field nested into an array field causes the result of the
payload.find()
to retrieve only a sublist of docs of the queried page.For example, with a limit of 20 and the filter on this date field, some pages will get 15 results, some other 13, etc, ... and the retrieved docs can be present in 2 distinct pages docs.
Note that when the
pagination
is set tofalse
, all the docs are retrieved normally, as it should be.To reproduce the issue, you can use the blank-starter template i did. I used the payload config
onInit
function to create 200 articles with random dates to help you.If you want to regenerate the data, you can delete all from the admin panel and restart your server.
Update
I manage to reproduce the issue from the payload version
3.35.1
to3.37.0
. I didn't test earlier versions.Link to the code that reproduces this issue
https://github.com/TheThingsWithin/payload-paginated-query-issue
Reproduction Steps
pnpm install
.env.example
into.env
and provide aPAYLOAD_SECRET
andDATABASE_URI
pnpm dev
http://localhost:3000/
LIMIT
constant anddocs.length
for each pagesLIMIT
constant insrc/app/(frontend)/page.tsx
file in order to test mutliple setupsLIMIT
constant to a higher value.Which area(s) are affected? (Select all that apply)
Not sure, area: core, db-postgres
Environment Info
The text was updated successfully, but these errors were encountered: