Commit 8239f5e
authored
fix: single-column BTree index Range filter/delete (#4737)
Fixes #4736
# Description of Changes
Single-column BTree indexes accepted `Range<T>` in their type signatures
(via `IndexScanRangeBounds`), but the runtime `filter()` and `delete()`
implementations always serialized the argument as a point value using
`datastore_index_scan_point_bsatn`. Passing a `Range` object caused
`SyntaxError: Cannot convert [object Object] to a BigInt` because the
Range object was fed directly to the column serializer.
The fix adds `Range` detection to the single-column BTree index code
path in `runtime.ts`. When a `Range` is passed, it serializes the bounds
and calls `datastore_index_scan_range_bsatn` /
`datastore_delete_by_index_scan_range_bsatn` instead. Point queries
continue to use the existing fast path. The multi-column index code
already handled `Range` correctly — this brings single-column indexes to
parity.
# API and ABI breaking changes
None. This is a pure bugfix. Existing queries are unaffected, and Range
queries that previously crashed now work as the types imply.
# Expected complexity level and risk
Low. The change is localized to one code path in `runtime.ts` and
mirrors the existing multi-column range serialization logic. All 170
existing tests pass.
# Testing
- All 170 vitest tests pass
- Manually confirmed the fix resolves the reported `SyntaxError` in a
production SpacetimeDB TypeScript module using
`ctx.db.players.fooId.filter(new Range(...))` on a single-column BTree
index1 parent fca10ae commit 8239f5e
1 file changed
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
670 | 689 | | |
671 | 690 | | |
672 | 691 | | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
673 | 701 | | |
674 | 702 | | |
675 | 703 | | |
| |||
680 | 708 | | |
681 | 709 | | |
682 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
683 | 719 | | |
684 | 720 | | |
685 | 721 | | |
| |||
0 commit comments