Skip to content

Commit 2fd582e

Browse files
committed
feat: support "create schema"
1 parent f2fa9a2 commit 2fd582e

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

crates/codegen/src/get_node_properties.rs

+12
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,18 @@ fn custom_handlers(node: &Node) -> TokenStream {
529529
"TypeCast" => quote! {
530530
tokens.push(TokenProperty::from(Token::Typecast));
531531
},
532+
"CreateSchemaStmt" => quote! {
533+
tokens.push(TokenProperty::from(Token::Create));
534+
tokens.push(TokenProperty::from(Token::Schema));
535+
if n.if_not_exists {
536+
tokens.push(TokenProperty::from(Token::IfP));
537+
tokens.push(TokenProperty::from(Token::Not));
538+
tokens.push(TokenProperty::from(Token::Exists));
539+
}
540+
if n.authrole.is_some() {
541+
tokens.push(TokenProperty::from(Token::Authorization));
542+
}
543+
},
532544
_ => quote! {},
533545
}
534546
}

crates/parser/src/codegen.rs

+17
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,21 @@ mod tests {
9191
],
9292
)
9393
}
94+
95+
#[test]
96+
fn test_create_schema() {
97+
test_get_node_properties(
98+
"create schema if not exists test authorization joe;",
99+
SyntaxKind::CreateSchemaStmt,
100+
vec![
101+
TokenProperty::from(SyntaxKind::Create),
102+
TokenProperty::from(SyntaxKind::Schema),
103+
TokenProperty::from(SyntaxKind::IfP),
104+
TokenProperty::from(SyntaxKind::Not),
105+
TokenProperty::from(SyntaxKind::Exists),
106+
TokenProperty::from(SyntaxKind::Authorization),
107+
TokenProperty::from("test".to_string()),
108+
],
109+
)
110+
}
94111
}

0 commit comments

Comments
 (0)