SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

fix subscription plan caching for client-specific views

Open joshua-spacetime opened this issue 1 month ago • 0 comments

Description of Changes

Fixes a subscription plan caching bug related to client-specific views.

Before this fix, you could define a client-specific view:

fn my_view(ctx: &ViewContext) -> Option<Player> {
    ctx.db.player().identity().find(ctx.sender)
}

And subscribe to it as follows:

SELECT * FROM my_view

Note this view is implicitly parameterized by :sender, however when generating a query hash for this subscription, this fact would not be taken into account which would result in this query being cached and reused for all callers.

After this fix, a query hash is generated for this subscription as though it were given as:

SELECT * FROM my_view WHERE identity = :sender

API and ABI breaking changes

None

Note for CLI code owners:

I had to touch the subscribe cli command file. No updates to the api. It just needed to be updated to look for views in the module def.

Expected complexity level and risk

1

Testing

  • [x] Added a regression smoketest

joshua-spacetime avatar Nov 17 '25 18:11 joshua-spacetime