fix: single-column BTree index Range filter/delete#4737
Open
DexterKoelson wants to merge 1 commit intoclockworklabs:masterfrom
Open
fix: single-column BTree index Range filter/delete#4737DexterKoelson wants to merge 1 commit intoclockworklabs:masterfrom
DexterKoelson wants to merge 1 commit intoclockworklabs:masterfrom
Conversation
The type system allowed Range<T> for single-column BTree index .filter() and .delete(), but the runtime always serialized the argument as a point value via datastore_index_scan_point_bsatn. Passing a Range object caused: SyntaxError: Cannot convert [object Object] to a BigInt Now detects Range instances and uses datastore_index_scan_range_bsatn for both filter and delete on single-column BTree indexes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4736
Description of Changes
Single-column BTree indexes accepted
Range<T>in their type signatures (viaIndexScanRangeBounds), but the runtimefilter()anddelete()implementations always serialized the argument as a point value usingdatastore_index_scan_point_bsatn. Passing aRangeobject causedSyntaxError: Cannot convert [object Object] to a BigIntbecause the Range object was fed directly to the column serializer.The fix adds
Rangedetection to the single-column BTree index code path inruntime.ts. When aRangeis passed, it serializes the bounds and callsdatastore_index_scan_range_bsatn/datastore_delete_by_index_scan_range_bsatninstead. Point queries continue to use the existing fast path. The multi-column index code already handledRangecorrectly — 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.tsand mirrors the existing multi-column range serialization logic. All 170 existing tests pass.Testing
SyntaxErrorin a production SpacetimeDB TypeScript module usingctx.db.players.fooId.filter(new Range(...))on a single-column BTree index