Deletions mutations have incorrect `original` and `changes` if they were previously updated
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- data
調査の方向性
Start at Transaction.applyMutations, where pending mutations are merged and where delete mutations get original, modified and changes all set to the deletion-time row. Read how PendingMutation is built for deletes and what collection._state.syncedData holds, using the update-then-delete sandbox to reproduce. Done means a delete after an update reports original from before the transaction, modified from just before deletion, and changes as their diff, with a regression test covering bulk updates plus a delete.
索引モデルが issue の本文から書いたものです。
説明
- I've validated the bug against the latest version of DB packages
Describe the bug
Deletion mutations have incorrect original and changes if they were previously updated.
To Reproduce
Steps to reproduce the behavior:
- Go to https://codesandbox.io/p/sandbox/yxwtgj
- Click on 'Update'
- Click on 'Delete'
- Observe that
originalandchangesare incorrect
Expected behavior
originalshould be the data since before the current transaction started,modifiedshould be the data before the deletion (might be the same asoriginalif no updates occurred during the transaction), andchangesshould be the difference betweenoriginalandmodified.
Additional context
I run the following fixDeletions workaround in Transaction.applyMutations, which I've monkey-patched:
function fixDeletions(
this: Transaction<any>,
mutations: PendingMutation<any>[],
): void {
// Merge via a globalKey-keyed map rather than a findIndex scan per
// mutation, which is O(n²) for bulk operations (e.g. inserting many rows
// in one call). Map preserves insertion order, matching the previous
// replace-in-place / remove / append semantics.
const merged = new Map<string, PendingMutation<any>>()
for (const mutation of this.mutations) {
merged.set(mutation.globalKey, mutation)
}
for (const newMutation of mutations) {
const { globalKey } = newMutation
if (newMutation.type !== 'delete') {
merged.set(globalKey, newMutation)
continue
}
// Deletions have `original`, `modified`, and `changes` set to the
// state at deletion time.
// `original` should be the actual original, `changes` should be the
// changes between `original` and `modified`
const original =
newMutation.collection._state.syncedData.get(newMutation.key) ?? newMutation.original
const { modified } = newMutation
const keys = new Set([...Object.keys(original), ...Object.keys(modified)])
const changes: Partial<Record<string, unknown>> = {}
for (const key of keys) {
if (
Object.hasOwn(original, key) !== Object.hasOwn(modified, key)
|| !sameRowValue(original[key], modified[key])
) {
changes[key] = modified[key]
}
}
merged.set(globalKey, {
...newMutation,
original,
changes,
})
}
// Rebuild in place to preserve the array's identity for external holders
this.mutations.length = 0
for (const mutation of merged.values()) {
this.mutations.push(mutation)
}
}
- 主要言語
- TypeScript
- スター
- 4k
- フォーク
- 286
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 105
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/db のほかの issue
-
extractSimpleComparisons returns value: null when the right side of a comparison isn't a literalオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
`avg`, `min`, `max` and `sum` treat `null` values as `0`対応中かも @oyobbeb が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
`Collection.currentStateAsChanges` JSDoc examples don’t match `CurrentStateAsChangesOptions`対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 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 が 23 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
inference/go type/feature
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
anomalyco/opencode#65148 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
truapi-release
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
paritytech/product-sdk#529 ·
メンテナーはふだん 1 日以内に返信
-
Add: Mansudae TVオープンapproved check:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
devlikeapro/waha#2369 ·
メンテナーはふだん 5 日以内に返信