Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions crates/bindings/bindings-doctests.sh

This file was deleted.

10 changes: 5 additions & 5 deletions crates/bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ pub use spacetimedb_bindings_macro::settings;
/// // The following line would panic, since we use `insert` rather than `try_insert`.
/// // let result = ctx.db.country().insert(Country { code: "CN".into(), national_bird: "Blue Magpie".into() });
///
/// // If we wanted to *update* the row for Australia, we can use the `update` method of `UniqueIndex`.
/// // The following line will succeed:
/// ctx.db.country().code().update(Country {
/// // If we wanted to replace the row for Australia, we can delete it and insert the new row.
/// assert!(ctx.db.country().code().delete("AU".to_string()));
/// ctx.db.country().insert(Country {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI says:

UniqueColumn::update is now constrained to primary-key columns only:

  pub fn update(&self, new_row: Tbl::Row) -> Tbl::Row
  where
      Col: PrimaryKey,

The docs in table.rs explicitly say this is intentional: for a non-primary unique column, use .delete(key) > followed by .insert(row). So the old text saying “update the row for Australia” with ctx.db.country().code().update(...) failed doctests because code is unique, not primary key.

/// code: "AU".into(), national_bird: "Australian Emu".into()
/// });
/// }
Expand Down Expand Up @@ -1118,7 +1118,7 @@ impl ReducerContext {
/// #[reducer]
/// fn generate_uuid_v4(ctx: &ReducerContext) -> Result<(), Box<dyn std::error::Error>> {
/// let uuid = ctx.new_uuid_v4()?;
/// log::info!(uuid);
/// log::info!("{uuid}");
/// Ok(())
/// }
/// # }
Expand All @@ -1140,7 +1140,7 @@ impl ReducerContext {
/// #[reducer]
/// fn generate_uuid_v7(ctx: &ReducerContext) -> Result<(), Box<dyn std::error::Error>> {
/// let uuid = ctx.new_uuid_v7()?;
/// log::info!(uuid);
/// log::info!("{uuid}");
/// Ok(())
/// }
/// # }
Expand Down
5 changes: 2 additions & 3 deletions crates/bindings/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ impl ReducerContext {
///
/// ```no_run
/// # #[cfg(target_arch = "wasm32")] mod demo {
/// use spacetimedb::{reducer, ReducerContext};
/// use rand::Rng;
/// use spacetimedb::{rand::Rng, reducer, ReducerContext};
///
/// #[spacetimedb::reducer]
/// fn rng_demo(ctx: &spacetimedb::ReducerContext) {
Expand All @@ -40,7 +39,7 @@ impl ReducerContext {
///
/// // Or, cache locally for reuse:
/// let mut rng = ctx.rng();
/// let floats: Vec<f32> = rng.sample_iter(rand::distributions::Standard).collect();
/// let floats: Vec<f32> = rng.sample_iter(spacetimedb::rand::distributions::Standard).collect();
/// }
/// # }
/// ```
Expand Down
6 changes: 3 additions & 3 deletions crates/bindings/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ pub trait IndexIsPointed: Index {}
///
/// ```no_run
/// # #[cfg(target_arch = "wasm32")] mod demo {
/// use spacetimedb::{table, PointIndex, ReducerContext, DbContext};
/// use spacetimedb::{table, DbContext, PointIndex, ReducerContext};
///
/// #[table(accessor = user,
/// index(accessor = dogs_and_name, hash(columns = [dogs, name])))]
Expand All @@ -537,7 +537,7 @@ pub trait IndexIsPointed: Index {}
///
/// ```no_run
/// # #[cfg(target_arch = "wasm32")] mod demo {
/// use spacetimedb::{table, PointIndex, ReducerContext, DbContext};
/// use spacetimedb::{table, DbContext, RangedIndex, ReducerContext};
///
/// #[table(accessor = user)]
/// struct User {
Expand All @@ -548,7 +548,7 @@ pub trait IndexIsPointed: Index {}
/// }
///
/// fn demo(ctx: &ReducerContext) {
/// let by_dogs: PointIndex<_, (u64,), _> = ctx.db().user().dogs();
/// let by_dogs: RangedIndex<_, (u64,), _> = ctx.db().user().dogs();
/// }
/// # }
/// ```
Expand Down
4 changes: 4 additions & 0 deletions tools/ci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ fn main() -> Result<()> {
.dir("crates/bindings-csharp")
.run()?;
cmd!("pnpm", "lint").run()?;
cmd!("cargo", "test", "--doc", "--target", "wasm32-unknown-unknown")
.dir("crates/bindings")
.run()?;
cmd!("cargo", "test", "--doc").dir("crates/bindings").run()?;
// `bindings` is the only crate we care strongly about documenting,
// since we link to its docs.rs from our website.
// We won't pass `--no-deps`, though,
Expand Down
Loading