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

Function strip_create_trigger_prefix

nodedb-sql/src/ddl_ast/parse/trigger.rs:122–138  ·  view source on GitHub ↗

Strip `CREATE [OR REPLACE] [SYNC|DEFERRED] TRIGGER ` prefix. Returns `(or_replace, execution_mode, original_rest)`.

(upper: &str, original: &'a str)

Source from the content-addressed store, hash-verified

120/// Strip `CREATE [OR REPLACE] [SYNC|DEFERRED] TRIGGER ` prefix.
121/// Returns `(or_replace, execution_mode, original_rest)`.
122fn strip_create_trigger_prefix<'a>(upper: &str, original: &'a str) -> (bool, String, &'a str) {
123 const PREFIXES: &[(&str, bool, &str)] = &[
124 ("CREATE OR REPLACE SYNC TRIGGER ", true, "SYNC"),
125 ("CREATE OR REPLACE DEFERRED TRIGGER ", true, "DEFERRED"),
126 ("CREATE OR REPLACE TRIGGER ", true, "ASYNC"),
127 ("CREATE SYNC TRIGGER ", false, "SYNC"),
128 ("CREATE DEFERRED TRIGGER ", false, "DEFERRED"),
129 ("CREATE TRIGGER ", false, "ASYNC"),
130 ];
131 for &(prefix, or_replace, mode) in PREFIXES {
132 if upper.starts_with(prefix) {
133 let rest = &original[prefix.len()..];
134 return (or_replace, mode.to_string(), rest);
135 }
136 }
137 (false, "ASYNC".to_string(), original)
138}
139
140/// Split trigger SQL into (header_original, header_upper, body_sql).
141/// Handles both `$$ ... $$` and `BEGIN ... END` body forms.

Callers 1

parse_create_triggerFunction · 0.85

Calls 2

to_stringMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected