SpacetimeDB
SpacetimeDB copied to clipboard
RLS: Add support for UNION ALL
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
");
We think this is required for RLS if e.g. you want your query to be x < 25 || x > 50
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.
Combining with #2442