MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / resolve_views_for_sub

Function resolve_views_for_sub

crates/expr/src/rls.rs:15–54  ·  view source on GitHub ↗

The main driver of RLS resolution for subscription queries. Mainly a wrapper around [resolve_views_for_expr].

(
    tx: &impl SchemaView,
    expr: ProjectName,
    auth: &AuthCtx,
    has_param: &mut bool,
)

Source from the content-addressed store, hash-verified

13/// The main driver of RLS resolution for subscription queries.
14/// Mainly a wrapper around [resolve_views_for_expr].
15pub fn resolve_views_for_sub(
16 tx: &impl SchemaView,
17 expr: ProjectName,
18 auth: &AuthCtx,
19 has_param: &mut bool,
20) -> anyhow::Result<Vec<ProjectName>> {
21 // RLS does not apply to the database owner
22 if auth.bypass_rls() {
23 return Ok(vec![expr]);
24 }
25
26 let Some(return_name) = expr.return_name().cloned() else {
27 anyhow::bail!("Could not determine return type during RLS resolution")
28 };
29
30 // Unwrap the underlying `RelExpr`
31 let expr = match expr {
32 ProjectName::None(expr) | ProjectName::Some(expr, _) => expr,
33 };
34
35 resolve_views_for_expr(
36 tx,
37 expr,
38 // Do not ignore the return table when checking for RLS rules
39 None,
40 // Resolve list is empty as we are not yet resolving any RLS rules
41 Rc::new(ResolveList::None),
42 has_param,
43 &mut 0,
44 auth,
45 )
46 .map(|fragments| {
47 fragments
48 .into_iter()
49 // The expanded fragments could be join trees,
50 // so wrap each of them in an outer project.
51 .map(|expr| ProjectName::Some(expr, return_name.clone()))
52 .collect()
53 })
54}
55
56/// The main driver of RLS resolution for sql queries.
57/// Mainly a wrapper around [resolve_views_for_expr].

Callers 3

resolve_views_for_sqlFunction · 0.85
resolveFunction · 0.85
compile_subscriptionFunction · 0.85

Calls 9

resolve_views_for_exprFunction · 0.85
bypass_rlsMethod · 0.80
return_nameMethod · 0.80
OkFunction · 0.50
newFunction · 0.50
mapMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…