nodedb-sql 0.0.6

SQL parser, planner, and optimizer for NodeDB
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Parse CREATE/DROP CHANGE STREAM.

use super::helpers::extract_name_after_if_exists;
use crate::ddl_ast::statement::NodedbStatement;

pub(super) fn try_parse(upper: &str, parts: &[&str], trimmed: &str) -> Option<NodedbStatement> {
    if upper.starts_with("CREATE CHANGE STREAM ") {
        return Some(NodedbStatement::CreateChangeStream {
            raw_sql: trimmed.to_string(),
        });
    }
    if upper.starts_with("DROP CHANGE STREAM ") {
        let if_exists = upper.contains("IF EXISTS");
        let name = extract_name_after_if_exists(parts, "STREAM")?;
        return Some(NodedbStatement::DropChangeStream { name, if_exists });
    }
    None
}