24 Commits

Author SHA1 Message Date
Shubham Mishra e4098f98d9 Rust: macro change name -> accessor (#4264)
## Description of Changes

This PR primarily affects the `bindings-macro` and `schema` crates to
review:

### Core changes

1. Replaces the `name` macro with `accessor` for **Tables, Views,
Procedures, and Reducers** in Rust modules.
2. Extends `RawModuleDefV10` with a new section for:

   * case conversion policies
   * explicit names
    New sections are not validated in this PR so not functional.
3. Updates index behavior:

* Index names are now always **system-generated** for clients. Which
will be fixed in follow-up PR when we start validating RawModuleDef with
explicit names.
   * The `accessor` name for an index is used only inside the module.


## Breaking changes (API/ABI)

1. **Rust modules**

   * The `name` macro must be replaced with `accessor`.

2. **Client bindings (all languages)**

* Index names are now system-generated instead of using explicitly
provided names.


**Complexity:** 3

A follow-up PR will reintroduce explicit names with support for case
conversion.

---------

Co-authored-by: rekhoff <r.ekhoff@clockworklabs.io>
Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
Co-authored-by: clockwork-labs-bot <bot@clockworklabs.com>
2026-02-16 15:23:50 +00:00
Tyler Cloutier 57b7ef5e79 Limit update() to only work on primary keys (#4279)
## Summary
- Restricts `update()` across all three server-side SDKs (Rust, C#,
TypeScript) to only work on primary key columns, not all unique columns
- Calling `update()` on a non-PK unique column is semantically a
delete+insert — clients won't see it as a row update unless the primary
key stays the same
- Fresh re-implementation of #1862, extended to cover C# and TypeScript
bindings

### Design principle

Primary key is a constraint on columns, not a property of indexes. An
index is unique or not unique — whether `update()` is available is
derived from the column's attributes at the point of use, not stored on
the index.

This differs from #1862 which introduced a `Uniqueness` enum (`No |
Unique | PrimaryKey`) on the index itself. Instead, we keep `is_unique:
bool` and check the column metadata where needed.

### Rust changes
- Add `PrimaryKey` marker trait and `where Col: PrimaryKey` bound on
`UniqueColumn::update()`
- `marker_type()` receives `primary_key_column` and checks the column
directly — no `is_pk` field on the index
- `sdk-test` unique tables use `update_non_pk_by` (delete+insert)
instead of `update_by`
- Benchmarks that used `update()` on `#[unique]` columns changed to
either `#[primary_key]` or delete+insert

### C# changes
- Only emit `Update()` on `UniqueIndex` when the column has `PrimaryKey`
attrs
- Update `unique_*` test reducers in `sdk-test-cs` to use
`Delete()`+`Insert()` instead

### TypeScript changes
- `UniqueIndex` now has only `find` + `delete` (no `update`)
- `AllColumnsPrimaryKey` type-level helper checks column metadata from
the `TableDef`
- `Index` routing conditionally intersects `{ update() }` when columns
are PK
- Runtime only attaches `update` method for PK unique indexes
- `sdk-test-ts` unique tables use delete+insert instead of update
- Type-level test in `schema.test-d.ts` verifies `id.update()` compiles
(PK) and `name2.update` errors (non-PK unique)

## Test plan
- [x] C# codegen tests pass (`dotnet test
crates/bindings-csharp/Codegen.Tests`)
- [x] Rust SDK test module compiles
- [x] Benchmarks compile
- [x] TypeScript type checks pass (`npx tsc --noEmit`)
- [ ] CI passes

Closes #1862
2026-02-13 00:56:54 +00:00
Mazdak Farrokhzad 50d58a2858 Add modules/benchmarks-ts (#3408)
# Description of Changes

Adds `modules/benchmarks-ts`.

# API and ABI breaking changes

None

# Expected complexity level and risk

2?

# Testing

This is a test.

---------

Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Noa <coolreader18@gmail.com>
2025-10-24 16:34:13 +00:00
Zeke Foppa b9d30991f1 Fix remaining LICENSE files (#3193)
# Description of Changes

Apparently, I missed several license files in #3002. I'm not sure what
method I was using to find them, but apparently it was insufficient.

**This replaces all empty `LICENSE` files with an explicit (symlink to)
BSL license, and all apache licenses with symlinks to the root apache
license.** This PR does not intentionally change any license terms, so
if you see one that changed, **it's a mistake**.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

```bash
$ find . -name '*LICENSE*' -type f | grep -v '\.meta$'
./crates/sqltest/standards/LICENSE # this one is an external library that we are not allowed to re-license
./LICENSE.txt # this is the root license
```

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-08-22 19:36:47 +00:00
Zeke Foppa 83f52cad97 Blackholio import - README updates (#2947)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-17 17:53:48 +00:00
Mario Montoya ee7970e752 Add .cargo/config.toml to spacetime init Rust project with default target to wasm (#2328) 2025-03-26 14:34:32 +00:00
Mario Montoya 04fd294627 Add missing LICENSE (#2319) 2025-02-28 14:32:59 +00:00
Mario Montoya 32e24b4095 Add README.md to all modules in SpacetimeDB/modules describing their usage (#2282) 2025-02-19 17:03:34 +00:00
Phoebe Goldman 91327d585e Make Timestamp a special SATS type (#1836)
Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-02-07 18:17:53 +00:00
Zeke Foppa a5feed08b0 Remove IO macros (#1929)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-12-03 19:39:24 +00:00
Mario Montoya cb9e0176e6 Fix benches for ia_loop, circles (#1922) 2024-11-05 14:50:31 +00:00
Ingvar Stepanyan 0935b7346b Fix Find() with struct-based rows (#1917) 2024-10-29 21:33:59 +00:00
Noa 53758420ec Rust module API rework (#1660) 2024-09-27 20:09:36 +00:00
Tyler Cloutier 3530498b88 Switched table names to singular (#1684)
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
2024-09-11 11:11:51 -04:00
Noa 8daab8e20f Impl macro rework (#1314) 2024-09-09 23:30:31 +00:00
Mario Montoya 814dd5b738 Add small 'realistic' workload benchmark integration test (#714) 2024-06-13 18:28:35 +00:00
james gilles a0a18ddd57 Rename types in benchmarks (#803)
* Rename types in benchmarks, modify benches run in action

* Fix lints
2024-02-23 20:30:59 +00:00
Noa 295ae3dd82 Fix benchmarks (#819) 2024-02-12 20:45:55 +00:00
Noa 37658aae7e Add rust-version to Cargo.toml (#802)
* Add rust-version to Cargo.toml

* Use workspace inheritance to make bumping the spacetime version easier
2024-02-07 20:02:05 +00:00
james gilles fa93200397 1_000_000 insert + update benchmarks (#764)
* Add 1_000_000 insert benches, disabled by default.

* memory architecture fix
2024-02-07 18:24:08 +00:00
james gilles 010c7e3c1e Wrangle benchmarks (#289)
Refactor benchmarks framework to allow direct comparison of spacetime modules, the spacetime datastore not through a module, and sqlite.
2023-09-29 23:12:12 +00:00
Mario Montoya 80a0a29704 Move cargo deps to the workspace (#172)
* Moving deps to workspace

* Merge
2023-08-11 15:24:31 -07:00
Phoebe Goldman 3e215322e5 [Modules] spacetimedb(index) macro now uses more consistent parens. (#97)
Prior to this comment, the `#[spacetimedb(index)]` attribute accepted its arguments like:

```rust
\#[spacetimedb(index(btree), name = "NAME", FIELD_NAMES...)]
```

Putting the `NAME` and `FIELD_NAMES` arguments outside of the
inner parens was uninutitive. With this commit, the syntax is changed to:

```rust

\#[spacetimedb(index(btree, name = "NAME", FIELD_NAMES...))]
```
2023-08-01 23:17:03 +02:00
Tyler Cloutier 44df6c6e7d Initial commit 2023-08-01 23:16:37 +02:00