extractSimpleComparisons returns value: null when the right side of a comparison isn't a literal
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- data
調査の方向性
null へのフォールバックは packages/db/src/query/expression-helpers.ts の390行目と472行目付近にあり、'Found complex expression' をスローするガードはその直後にあります。まず、issue にある3つの呼び出しを extractSimpleComparisons に対して再現してください。これらの呼び出しが右辺がリテラルでない場合にエラーをスローし、一方で eq(row.a, null) は引き続き value: null を返し、両方のケースを対象とするテストがある状態を完了とします。
索引モデルが issue の本文から書いたものです。
説明
- I've validated the bug against the latest version of DB packages
Describe the bug
extractSimpleComparisons is documented to throw on expressions it can't represent as a simple comparison, but a comparison whose right side is a column or a function doesn't throw. It returns value: null, so a queryFn built on it sends a filter against null to the backend with no error.
When the right side isn't a literal it falls back to null (expression-helpers.ts:390 and :472), and the guard after it only rejects undefined, so the "Found complex expression" error can't fire for this case.
To Reproduce
import { IR, extractSimpleComparisons } from "@tanstack/db"
const a = new IR.PropRef(["a"])
const b = new IR.PropRef(["b"])
console.log(extractSimpleComparisons(new IR.Func("eq", [a, b])))
console.log(extractSimpleComparisons(new IR.Func("eq", [a, new IR.Func("lower", [b])])))
console.log(extractSimpleComparisons(new IR.Func("not", [new IR.Func("gt", [a, b])])))
This prints:
[ { field: [ 'a' ], operator: 'eq', value: null } ]
[ { field: [ 'a' ], operator: 'eq', value: null } ]
[ { field: [ 'a' ], operator: 'not_gt', value: null } ]
The same happens through a live query. On an on-demand collection, .where(({ row }) => eq(row.a, lower(row.b))) passes loadSubset a where that extractSimpleComparisons reads as { field: ['a'], operator: 'eq', value: null }.
Expected behavior
These calls throw extractSimpleComparisons requires simple field-value comparisons. Found complex expression for 'eq' operator. (or 'not(gt)'), as they would for any other expression it can't represent. A literal null, such as eq(row.a, null), should keep returning value: null.
Additional context
@tanstack/db 1.0.0-rc.1.4, Node 24.12.0. The lines above are unchanged on main at 6ec538ecd.
Falling back to undefined instead of null at those two lines would let the existing guard throw. I can open a PR if that looks right to you.
- 主要言語
- TypeScript
- スター
- 4k
- フォーク
- 286
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 104
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/db のほかの issue
-
`avg`, `min`, `max` and `sum` treat `null` values as `0`対応中かも @oyobbeb が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Two @tanstack/db tests time out under CPU load because a cold module import counts against the 5 s default timeout対応中かも @jp-knj が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
bot:ai-assisted component:platform-js status:untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
midnightntwrk/platform-js#38 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ranxianglei/billion-context#7068 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
mybigday/whisper.rn#348 ·
-
enhancement severity:low
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Battle-Cattle/BCUK-Bot-4#1075 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
ilan-pinto/roaring-lions#1552 ·
メンテナーはふだん 1 日以内に返信