SpacetimeDB
SpacetimeDB copied to clipboard
Better detection and error messages for indexes with unsupported key types
Currently, the UX of restricted index key types is pretty poor. You don't get a compile-time error when creating the index, you just don't have access to the filtering methods. The client SDKs also inconsistently or incorrectly do/don't emit client-side indexes when the module declares an index of unsupported type.
We've seen a few different users in the public Discord stumble on this.
Definition of Done:
- In the Rust module bindings library, it is a hard compile-time error to declare a BTree, unique or primary_key index on (a) column(s) which do(es) not implement
FilterableValue. - In the C# module bindings library, it is a hard compile-time error to declare a BTree, unique or primary_key index on (a) column(s) whose type(s) is/are not "filterable," i.e. the same set of types as in Rust implement
FilterableValue. - In the Rust client SDK, it is possible to
spacetime generatebindings for a module with an index whose types are not filterable. The resulting bindings compile and run without error, but do not contain the ill-typed index. That is,spacetime generatefor the Rust client SDK skips indexes with non-filterable key types. A warning is printed to the console when skipping such an index duringspacetime generate.- This should be unreachable due to the above restrictions, but I expect we'll encounter modules that bypass those restrictions in various ways.
- In the TypeScript client SDK, it is possible to
spacetime generatebindings for a module with an index whose types are not filterable. The resulting bindings compile and run without error, but do not contain the ill-typed index. That is,spacetime generatefor the TypeScript client SDK skips indexes with non-filterable key types. A warning is printed to the console when skipping such an index duringspacetime generate. - In the C#/Unity Client SDK, it is possible to
spacetime generatebindings for a module with an index whose types are not filterable. The resulting bindings compile and run without error, but do not contain the ill-typed index. That is,spacetime generatefor the Rust client SDK skips indexes with non-filterable key types. A warning is printed to the console when skipping such an index duringspacetime generate.