mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-10 17:49:49 -04:00
85095cfa85
This fixes an issue with the C# implementation of Query Builder requiring `Build()` to return a query, and the return type being `Query<TRow>` rather than `IQuery<TRow>`. # Description of Changes 1. Runtime/query-builder * Removed the concrete `Query<TRow>` carrier type and every `.Build()`. Query builder shapes now expose only `IQuery<TRow>` plus `ToSql()`. * Ensured all builder entry points (tables, joins, filters) continue to return `IQuery<TRow>`. 2. Source generator + bindings * Updated `ViewDeclaration` analysis to treat any return type implementing `SpacetimeDB.IQuery<TRow>` as a SQL view. * Dispatcher generation now emits `ViewResultHeader.RawSql(returnValue.ToSql())` . This eliminates a `Query<TRow>` special-case. 3. Tests, fixtures, regression module * Converted the C# query-builder unit tests, codegen fixtures, and regression-test server views to call `ToSql()`/return `IQuery<TRow>`. * Added coverage proving `RightSemiJoin` (and friends) still satisfy `IQuery<TRow>`. 4. CLI templates & generated bindings * Regenerated/edited C# template bindings so `SubscriptionBuilder.AddQuery` accepts `Func<QueryBuilder, IQuery<TRow>>` and captures SQL via `ToSql()`. # API and ABI breaking changes While technically API breaking, this actually brings the API closer to the intended design. * `Query<TRow>` has been removed from the public surface area; any previous references (including `.Build()` and `.Sql`) must be replaced with the builder instance itself plus `.ToSql()`. * View methods must now return an `IQuery<TRow>` (or any custom type implementing it) when producing SQL for the host. * Generated C# client bindings now expect typed subscription callbacks to produce `IQuery<TRow>`, aligning the client SDK with the new runtime contract. # Expected complexity level and risk 3 - Medium: Touches runtime, codegen, fixtures, and templates. Risk is mitigated by parity with Rust semantics and comprehensive test updates, but downstream modules must recompile to adopt the new interface. # Testing - [X] Built CLI and ran regression tests locally with removed `.Build()` - [X] Ran `dotnet test .\sdks\csharp\tests~\tests.csproj -c Release` with all tests passing - [X] Ran `dotnet test .\crates\bindings-csharp\Codegen.Tests\Codegen.Tests.csproj -c Release` with all tests passing