Support Timestamp and TimeDuration filtering by clockwork-labs-bot · Pull Request #4813 · clockworklabs/SpacetimeDB

Closes #2650.

What changed

  • add Rust FilterableValue support for Timestamp and TimeDuration
  • extend TypeScript query/filter literal handling for TimeDuration
  • make C# TimeDuration implement IComparable<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.rs
    • Timestamp and TimeDuration now implement FilterableValue
  • Rust client cache: sdks/rust/src/client_cache.rs
    • adds unit tests proving the Rust SDK's unique-index cache accepts both Timestamp and TimeDuration keys
  • TypeScript client:
    • crates/bindings-typescript/src/lib/query.ts handles TimeDuration in query literal/comparison paths
    • crates/bindings-typescript/tests/query.test.ts covers SQL/query-side behavior
    • crates/bindings-typescript/tests/algebraic_type.test.ts covers AlgebraicType.intoMapKey(...) for Timestamp and TimeDuration, which is the key path used by the TS client cache/index machinery
  • C# client:
    • crates/bindings-csharp/BSATN.Runtime/Builtins.cs gives TimeDuration the IComparable<TimeDuration> implementation required by the C# index types
    • sdks/csharp/tests~/QueryBuilderTests.cs now exercises indexed-column query expressions for both Timestamp and TimeDuration
    • crates/bindings-csharp/BSATN.Runtime.Tests/Tests.cs adds runtime/hash coverage for TimeDuration

Validation

Passed locally:

  • cargo test -p spacetimedb-lib filterable_value::tests::timestamp_and_time_duration_are_filterable -- --exact
  • cargo check --manifest-path sdks/rust/Cargo.toml --lib
  • pnpm --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 native rusty_v8
  • dotnet test for the C# test projects, because dotnet is not installed on this host