SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Document and regression-test `table(scheduled(at = col_name))` syntax

Open gefjon opened this issue 8 months ago • 1 comments

From our macro code:

let scheduled_at_column = scheduled_at_column.ok_or_else(|| {
    syn::Error::new(
        sched.span,
        "scheduled tables must have a `scheduled_at: spacetimedb::ScheduleAt` column. \
                 if the column has a name besides `scheduled_at`, you can specify it with \
                 `scheduled(my_reducer, at = custom_scheduled_at)`",
    )
})?;

This syntax, with the at = col_name parameter supplied, does not appear in our docs, and is not regression-tested. Add a use of this syntax to the module-test module so that it gets built in CI, and also expand the docs of scheduled reducers, which are attached to the spacetimedb_bindings_table re-export in the bindings crate's lib.rs.

gefjon avatar Apr 04 '25 19:04 gefjon

I'm experiencing issues with this right now:

spacetime publish vibe-survival-game
game                              Compiling vibe-survival-game
 v0.1.0 (C:\Users\Asus\OneDrive\Documents\WebProjects\vibe-coding-starter-pack-2d-survival\server)                          error: expected parentheses   
   --> src\campfire.rs:286:32
    |
286 | ...heduled = consume_...
    |            ^

error[E0422]: cannot find struc
t, variant or union type `CampfireFuelConsumeSchedule` in this scope                            --> src\campfire.rs:302:56
    |
302 | ...rt(CampfireFuelConsume
Schedul...                         |       ^^^^^^^^^^^^^^^^^^^
^^^^^^^^ not found in this scope                              
error[E0599]: no method named `
campfire_fuel_consume_schedule` found for struct `Local` in the current scope                   --> src\campfire.rs:302:12
    |
302 | ...db.campfire_fuel_consu
me_schedule()....                  |       ^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^ method not found in `Local`                       
Some errors have detailed expla
nations: E0422, E0599.         For more information about an e
rror, try `rustc --explain E0422`.                            error: could not compile `vibe-
survival-game` (lib) due to 3 previous errors                 Error: command ["cargo", "build
", "--config=net.git-fetch-with-cli=true", "--target=wasm32-unknown-unknown", "--release", "--message-format=json-render-dia

SeloSlav avatar Apr 17 '25 09:04 SeloSlav

I split up this ticket; the regression-testing part is now in https://github.com/clockworklabs/SpacetimeDB/issues/3120

bfops avatar Aug 04 '25 16:08 bfops