Skip to content
Source
Sign inSign up
TanStack/db

fix(db): unify ordered window semantics #1778

ClosedKyleAMathews(GitHub profile, opens in a new tab)wants to merge 99 commits intocodex/loadsubset-coverage-registry fromcodex/loadsubset-total-orderopened

Showing 39 changed files with 23 additions and 1 deletion (loading 36).

x
0 of 39 viewed, 39 left
6 additions and 0 deletions.changeset/unify-ordered-window-semantics.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/db': patch
+'@tanstack/db-ivm': patch
+---
+​
+Use one total order and applied row provenance for lazy ordered windows so cursor pagination, live updates, and window replay preserve exact results.
8 additions and 0 deletionspackages/db-ivm/src/utils.tsModified
View file
@@ -185,6 +185,14 @@
export function compareKeys(a: string | number, b: string | number): number {
// Same type: compare directly
if (typeof a === typeof b) {
+ if (typeof a === `number` && typeof b === `number`) {
+ const aIsNaN = Number.isNaN(a)
+ const bIsNaN = Number.isNaN(b)
+ if (aIsNaN || bIsNaN) {
+ if (aIsNaN && bIsNaN) return 0
+ return aIsNaN ? 1 : -1
+ }
+ }
if (a < b) return -1
if (a > b) return 1
return 0