clockworklabs / clockworklabs/SpacetimeDB

Table subscriptions do not trigger when mutating tables using `spacetime sql` or HTTP SQL API

Open
#256 0 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

possibly-stale
Dominant language
Rust
Stars
25.2k
Forks
1.1k
Avg merge
2d 7h
Merged PRs (30d)
46

Description

When mutating subscribed tables spacetimedb does not trigger on_insert, on_update or on_delete events when using spacetime sql or HTTP SQL API interface, it seems these events fire currently only when using rust-land functions inside server-side code.

Reproduction

Create server-side module that creates User and adds it to the table in identity_connected, when we connect, the user gets inserted and on_insert on the client-side triggers correctly, but when we call e.g spacetime sql spacetime "DELETE FROM User" the User::on_delete listener does not trigger at all but it would trigger if we deleted the record using server-side User::delete or User::delete_by_ function.

mod module_bindings;
use module_bindings::*;

const URI: &str = "http://localhost:3000";
const DB_NAME: &str = "spacetime";

use spacetimedb_sdk::{
    identity::on_connect,
    on_subscription_applied, subscribe,
    table::{TableType, TableWithPrimaryKey},
};

fn main() {
    User::on_insert(|user, _| println!("User inserted: {:?}", user));
    User::on_delete(|user, _| println!("User deleted: {:?}", user));

    on_connect(|_| subscribe(&["SELECT * FROM User;"]).expect("Subscribe failed"));

    connect(URI, DB_NAME, None).expect("Connect failed");

    loop {}
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.