holocron 0.3.0

Declarative schema & query compiler — one YAML as the source of truth for SQL schema and a type-checked query catalog.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::ast::EnumType;
use crate::emit::{quote_ident, quote_literal};

/// Emit `CREATE TYPE <name> AS ENUM ('v1', 'v2', ...);`.
pub(crate) fn emit(output: &mut String, declared: &EnumType) {
    output.push_str("CREATE TYPE ");
    output.push_str(&quote_ident(&declared.name.value));
    output.push_str(" AS ENUM (");
    let values: Vec<String> = declared
        .r#enum
        .iter()
        .map(|value| quote_literal(&value.value))
        .collect();
    output.push_str(&values.join(", "));
    output.push_str(");\n\n");
}