db-postgres: date-only range on a single field drops every operator after the first (greater_than_equal + less_than_equal)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 88/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- postgresql, typescript
Línea de trabajo
Empieza en packages/drizzle/src/queries/parseParams.ts e inspecciona el bucle de operadores por campo alrededor de getDateOnlyComparison. Añade una prueba de regresión para dos límites de fecha sin hora en un mismo campo, incluido el orden inverso de los operadores; la reproducción mínima del issue espera que totalDocs sea 31. Confirma que se aplican ambos límites y que las consultas existentes con un solo límite y las consultas con marcas de tiempo completas siguen funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the Bug
Since 3.94.0, a where with two comparison operators on the same date field, both given as date-only strings (YYYY-MM-DD), applies only the first operator. The second one is silently ignored. No error is raised; the query just returns too many documents.
await payload.find({
collection: 'events',
where: {
date: {
greater_than_equal: '2027-05-01',
less_than_equal: '2027-05-31', // ignored
},
},
})
// → every event on or after 2027-05-01, not just May
Splitting the same range into and works correctly:
where: {
and: [
{ date: { greater_than_equal: '2027-05-01' } },
{ date: { less_than_equal: '2027-05-31' } },
],
}
// → only May
Combined with a limit, this turns into wrong data rather than just extra rows. With limit: 31 and the default sort, the result is mostly documents from later months. That is how we hit it: a per-day pricing calendar started showing default values for days whose rows existed.
Cause: packages/drizzle/src/queries/parseParams.ts. The per-field loop
for (let operator of Object.keys(pathOperators)) {
handles each operator in turn. The new date-only branch (from getDateOnlyComparison) ends in break:
const dateOnlyComparison = getDateOnlyComparison({ config: adapter.payload.config, field, operator: originalOperator, value: val })
if (dateOnlyComparison) {
const range = and(...dateOnlyComparison.constraints.map(/* … */))
constraints.push(dateOnlyComparison.isNegated ? or(isNull(resolvedColumn), not(range)) : range)
break // ← leaves the operator loop, so the remaining operators on this path are never processed
}
break exits for (operator of …), not just the current operator's handling. The comment just above the loop says "there can be multiple comparisons on a single path … loop on keys again here to handle each operator independently". The date-only branch breaks that contract. continue (or collecting the constraints and continuing) would keep the remaining operators.
Scope:
- Only
datefields whereisDateOnlyFilteris true (pickerAppearancedefault/dayOnly), with values that matchYYYY-MM-DD. - Full ISO timestamps (
2027-05-01T00:00:00.000Z) don't take this branch and still work. - Seen in 3.94.1 and still present in 3.94.2 (the compiled
dist/queries/parseParams.jsis identical in that block). - Not checked:
db-mongodb.
Link to the code that reproduces this issue
Minimal repro, any collection with a plain date field on @payloadcms/db-postgres ≥ 3.94.0:
// collection
{ slug: 'events', fields: [{ name: 'date', type: 'date', required: true }] }
// seed: one doc per day for 2027-05-01 … 2027-06-30 (61 docs)
const { totalDocs } = await payload.find({
collection: 'events',
where: { date: { greater_than_equal: '2027-05-01', less_than_equal: '2027-05-31' } },
limit: 0,
})
expect(totalDocs).toBe(31) // actual: 61
Reproduction Steps
- Create a collection with a
datefield (nopickerAppearance, notimezone). - Insert documents across two consecutive months.
- Query with
date: { greater_than_equal: 'YYYY-MM-01', less_than_equal: 'YYYY-MM-31' }for the first month. - Observe that documents from the second month are returned (the upper bound is ignored).
- Swap the operator order (
less_than_equalfirst): now the lower bound is ignored.
Expected: both bounds apply, as in ≤ 3.93 and as with the equivalent and query.
Which area(s) are affected?
db-postgres (@payloadcms/drizzle), likely also db-sqlite / db-vercel-postgres since they share parseParams.
Environment Info
payload: 3.94.1 (also 3.94.2)
@payloadcms/db-postgres: 3.94.1
@payloadcms/drizzle: 3.94.1
Node: 24.23.0
Postgres: 17.9
Last working version: 3.93.0 (getDateOnlyComparison is absent from parseParams in 3.93.0, present from 3.94.0)
- Lenguaje dominante
- TypeScript
- Estrellas
- 46.1k
- Forks
- 4.5k
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 238
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de payloadcms/payload
-
website template: the seed button fails intermittently with a deadlock, because the seed clears collections in parallelPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea: templates Bug db: postgres Payload OSS
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
payloadcms/payload#20019 ·
Los mantenedores suelen responder en 1 día
-
Uploading a file whose name ends in a long number loops forever when the name is takenPosiblemente ocupada @JayPokale la tomó hace 7 días. Abiertoarea: core Bug community-pr Payload OSS
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
payloadcms/payload#19978 ·
Los mantenedores suelen responder en 1 día
-
[v4] A row whose fields are all hidden by their conditions still adds a field margin (regression from v3)Posiblemente ocupada @paulw1982 la tomó hace 7 días. Abiertoarea: ui Bug community-pr created-by: Contributor Payload OSS status: needs-triage v3-only
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
payloadcms/payload#19976 ·
Los mantenedores suelen responder en 1 día
-
[v3] Maximum update depth exceeded opening a document from the list view with cacheComponents: true (dev): backport #18702's CloseModalOnRouteChange guardQuizá libre de nuevo @MuhammadAhmad67889 la tomó hace 8 días y no hay ningún pull request abierto. Abiertoarea: ui Bug Payload OSS
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
payloadcms/payload#19954 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
refresh operation throws a TypeError (500) when the session is revoked between the JWT strategy read and its own readPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea: core Bug Payload OSS
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
payloadcms/payload#19867 ·
Los mantenedores suelen responder en 1 día
Todos los issues de payloadcms/payload
Issues similares
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
novuhq/novu#13613 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
enhancement from-app needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
nightly-labs/openbot#23943 ·
Los mantenedores suelen responder en 1 día
-
comp/desktop desktop/chat P3 type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
NousResearch/hermes-agent#164451 ·
Los mantenedores suelen responder en 1 día
-
shortkeys-2188:ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
crittermike/shortkeys#1121 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Doist/todoist-cli#742 ·