db-postgres: date-only range on a single field drops every operator after the first (greater_than_equal + less_than_equal)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- postgresql, typescript
調査の方向性
packages/drizzle/src/queries/parseParams.ts から始めて、getDateOnlyComparison 周辺のフィールドごとの演算子ループを調べてください。同じフィールドに対する時刻なしの日付境界が2つある場合の回帰テストを追加し、演算子の順序を逆にした場合も含めてください。issue の最小再現例では totalDocs が31になることを想定しています。両方の境界が適用され、既存の単一境界のクエリと完全なタイムスタンプを使うクエリが引き続き動作することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- TypeScript
- スター
- 46.1k
- フォーク
- 4.5k
- 平均マージ
- 2日 15時間
- マージ済み PR(30日)
- 238
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
payloadcms/payload のほかの issue
-
website template: the seed button fails intermittently with a deadlock, because the seed clears collections in parallel対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンarea: templates Bug db: postgres Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
payloadcms/payload#20019 ·
メンテナーはふだん 1 日以内に返信
-
Uploading a file whose name ends in a long number loops forever when the name is taken対応中かも @JayPokale が 7 日前に担当しました。 オープンarea: core Bug community-pr Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
payloadcms/payload#19978 ·
メンテナーはふだん 1 日以内に返信
-
[v4] A row whose fields are all hidden by their conditions still adds a field margin (regression from v3)対応中かも @paulw1982 が 7 日前に担当しました。 オープンarea: ui Bug community-pr created-by: Contributor Payload OSS status: needs-triage v3-only
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
payloadcms/payload#19976 ·
メンテナーはふだん 1 日以内に返信
-
[v3] Maximum update depth exceeded opening a document from the list view with cacheComponents: true (dev): backport #18702's CloseModalOnRouteChange guard再び着手できるかも @MuhammadAhmad67889 が 8 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンarea: ui Bug Payload OSS
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
payloadcms/payload#19954 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
refresh operation throws a TypeError (500) when the session is revoked between the JWT strategy read and its own read対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンarea: core Bug Payload OSS
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
payloadcms/payload#19867 ·
メンテナーはふだん 1 日以内に返信
payloadcms/payload の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Vessel9817/onion-site-template#512 ·
メンテナーはふだん 1 日以内に返信
-
nightly-tests
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
メンテナーはふだん 1 日以内に返信
-
approved
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
fritzprix/libr-agent#3266 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
better-auth/better-auth#13101 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信