Support Timestamp and TimeDuration filtering by clockwork-labs-bot · Pull Request #4813 · clockworklabs/SpacetimeDB
Closes #2650.
What changed
- add Rust
FilterableValuesupport forTimestampandTimeDuration - extend TypeScript query/filter literal handling for
TimeDuration - make C#
TimeDurationimplementIComparable<TimeDuration> - add client-focused coverage so the issue comment's “make sure the clients work too” ask is explicitly covered
Completeness for the #2650 comment
This PR now covers both the backend change and the client-side pieces the comment thread asked for:
- Rust backend:
crates/lib/src/filterable_value.rsTimestampandTimeDurationnow implementFilterableValue
- Rust client cache:
sdks/rust/src/client_cache.rs- adds unit tests proving the Rust SDK's unique-index cache accepts both
TimestampandTimeDurationkeys
- adds unit tests proving the Rust SDK's unique-index cache accepts both
- TypeScript client:
crates/bindings-typescript/src/lib/query.tshandlesTimeDurationin query literal/comparison pathscrates/bindings-typescript/tests/query.test.tscovers SQL/query-side behaviorcrates/bindings-typescript/tests/algebraic_type.test.tscoversAlgebraicType.intoMapKey(...)forTimestampandTimeDuration, which is the key path used by the TS client cache/index machinery
- C# client:
crates/bindings-csharp/BSATN.Runtime/Builtins.csgivesTimeDurationtheIComparable<TimeDuration>implementation required by the C# index typessdks/csharp/tests~/QueryBuilderTests.csnow exercises indexed-column query expressions for bothTimestampandTimeDurationcrates/bindings-csharp/BSATN.Runtime.Tests/Tests.csadds runtime/hash coverage forTimeDuration
Validation
Passed locally:
cargo test -p spacetimedb-lib filterable_value::tests::timestamp_and_time_duration_are_filterable -- --exactcargo check --manifest-path sdks/rust/Cargo.toml --libpnpm --filter ./crates/bindings-typescript test -- tests/algebraic_type.test.ts tests/query.test.ts
Could not run locally on this host:
cargo test --manifest-path sdks/rust/Cargo.toml --lib ...currently pulls in a dev-dependency graph that fails here on missing nativerusty_v8dotnet testfor the C# test projects, becausedotnetis not installed on this host