Skip to content

Commit 86ad40c

Browse files
fix(db) loadSubset when orderby has multiple columns (#926)
* fix(db) loadSubset when orderby has multiple columns failing test for multiple orderby and loadsubset push down multiple orderby predicates to load subset split order by cursor predicate build into two, inprecise wider band for local lading, precise for the sync loadSubset new e2e tests for composite orderby and pagination changeset when doing gt/lt comparisons to a bool cast to string fix: use non-boolean columns in multi-column orderBy e2e tests Electric/PostgreSQL doesn't support comparison operators (<, >, <=, >=) on boolean types. Changed tests to use age (number) and name (string) columns instead of isActive (boolean) to avoid this limitation. The core multi-column orderBy functionality still works correctly - this is just a test adjustment to work within Electric's SQL parser constraints. * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 09da081 commit 86ad40c

File tree

9 files changed

+1366
-86
lines changed

9 files changed

+1366
-86
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@tanstack/db': patch
3+
---
4+
5+
Enhanced multi-column orderBy support with lazy loading and composite cursor optimization.
6+
7+
**Changes:**
8+
9+
- Create index on first orderBy column even for multi-column orderBy queries, enabling lazy loading with first-column ordering
10+
- Pass multi-column orderBy to loadSubset with precise composite cursors (e.g., `or(gt(col1, v1), and(eq(col1, v1), gt(col2, v2)))`) for backend optimization
11+
- Use wide bounds (first column only) for local index operations to ensure no rows are missed
12+
- Use precise composite cursor for sync layer loadSubset to minimize data transfer
13+
14+
**Benefits:**
15+
16+
- Multi-column orderBy queries with limit now support lazy loading (previously disabled)
17+
- Sync implementations (like Electric) can optimize queries using composite indexes on the backend
18+
- Local collection uses first-column index efficiently while backend gets precise cursor

0 commit comments

Comments
 (0)