SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

RLS: Add support for UNION ALL

Open joshua-spacetime opened this issue 1 year ago • 1 comments

I.e. bag or multiset union. You may define multiple RLS filters on the same table, the semantics of which are that of a bag union. For example:

/// A user only has access to their row
#[spacetimedb::client_visibility_filter]
const USER_FILTER: Filter = Filter::Sql("
    SELECT * FROM user WHERE identity = @sender
");

/// But the module owner has access to everything
#[spacetimedb::client_visibility_filter]
const USER_FILTER: Filter = Filter::Sql("
    SELECT user.*
    FROM user JOIN st_module
    WHERE st_module.owner_identity = @sender
");

joshua-spacetime avatar Aug 16 '24 20:08 joshua-spacetime

We think this is required for RLS if e.g. you want your query to be x < 25 || x > 50

bfops avatar Nov 20 '24 21:11 bfops

Note, this does not require that we add UNION ALL to Spacetime SQL, but it will need to be supported by the logical query plan and execution engine.

joshua-spacetime avatar Mar 19 '25 03:03 joshua-spacetime

Combining with #2442

joshua-spacetime avatar Mar 24 '25 17:03 joshua-spacetime