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

Method build_row_level_expr

crates/engine/src/sql/rls.rs:17–42  ·  view source on GitHub ↗
(
        tx: &mut MutTxId,
        auth_ctx: &AuthCtx,
        rls: &RawRowLevelSecurityDefV9,
    )

Source from the content-addressed store, hash-verified

15
16impl RowLevelExpr {
17 pub fn build_row_level_expr(
18 tx: &mut MutTxId,
19 auth_ctx: &AuthCtx,
20 rls: &RawRowLevelSecurityDefV9,
21 ) -> anyhow::Result<Self> {
22 let (sql, _) = parse_and_type_sub(&rls.sql, &SchemaViewer::new(tx, auth_ctx), auth_ctx)?;
23 let table_id = sql.return_table_id().unwrap();
24 let schema = tx.schema_for_table(table_id)?;
25
26 match schema.table_access {
27 StAccess::Private => {
28 anyhow::bail!(
29 "Cannot define RLS rule on private table: {}. \
30 Please make table public if you wish to restrict access using RLS.",
31 schema.table_name
32 )
33 }
34 StAccess::Public => Ok(Self {
35 def: RowLevelSecuritySchema {
36 table_id,
37 sql: rls.sql.clone(),
38 },
39 sql,
40 }),
41 }
42 }
43}

Callers

nothing calls this directly

Calls 7

return_table_idMethod · 0.80
parse_and_type_subFunction · 0.50
newFunction · 0.50
OkFunction · 0.50
unwrapMethod · 0.45
schema_for_tableMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected