MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / try_parse_alter_tenant

Function try_parse_alter_tenant

nodedb-sql/src/ddl_ast/parse/tenant.rs:35–73  ·  view source on GitHub ↗
(
    _upper: &str,
    parts: &[&str],
    original: &str,
)

Source from the content-addressed store, hash-verified

33// ── ALTER TENANT ──────────────────────────────────────────────────────────────
34
35fn try_parse_alter_tenant(
36 _upper: &str,
37 parts: &[&str],
38 original: &str,
39) -> Option<Result<NodedbStatement, SqlError>> {
40 // ALTER TENANT <name> IN DATABASE <db> SET QUOTA (...)
41 // parts: [ALTER, TENANT, <name>, IN, DATABASE, <db>, SET, QUOTA, ...]
42 if parts.len() < 3 {
43 return None;
44 }
45 if !parts[1].eq_ignore_ascii_case("TENANT") {
46 return None;
47 }
48
49 // Must have IN DATABASE at positions 3,4 (0-indexed).
50 if parts.len() < 8 {
51 return None;
52 }
53 if !parts[3].eq_ignore_ascii_case("IN") || !parts[4].eq_ignore_ascii_case("DATABASE") {
54 return None;
55 }
56 if !parts[6].eq_ignore_ascii_case("SET") || !parts[7].eq_ignore_ascii_case("QUOTA") {
57 return None;
58 }
59
60 let name = parts[2].to_string();
61 let database = parts[5].to_string();
62
63 let spec = match parse_quota_spec(original, "ALTER TENANT IN DATABASE SET QUOTA") {
64 Ok(s) => s,
65 Err(e) => return Some(Err(e)),
66 };
67
68 Some(Ok(NodedbStatement::Database(DatabaseStmt::AlterTenant {
69 name,
70 database,
71 operation: AlterTenantOperation::SetQuota(spec),
72 })))
73}
74
75// ── SHOW TENANT ───────────────────────────────────────────────────────────────
76

Callers 1

try_parseFunction · 0.85

Calls 3

parse_quota_specFunction · 0.85
to_stringMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected