diff --git a/crates/codegen/src/get_node_properties.rs b/crates/codegen/src/get_node_properties.rs index d4ebe070..9da04fb7 100644 --- a/crates/codegen/src/get_node_properties.rs +++ b/crates/codegen/src/get_node_properties.rs @@ -536,6 +536,18 @@ fn custom_handlers(node: &Node) -> TokenStream { tokens.push(TokenProperty::from(Token::As)); } }, + "CreateSchemaStmt" => quote! { + tokens.push(TokenProperty::from(Token::Create)); + tokens.push(TokenProperty::from(Token::Schema)); + if n.if_not_exists { + tokens.push(TokenProperty::from(Token::IfP)); + tokens.push(TokenProperty::from(Token::Not)); + tokens.push(TokenProperty::from(Token::Exists)); + } + if n.authrole.is_some() { + tokens.push(TokenProperty::from(Token::Authorization)); + } + }, _ => quote! {}, } } diff --git a/crates/parser/src/codegen.rs b/crates/parser/src/codegen.rs index ca18cdf9..dab36130 100644 --- a/crates/parser/src/codegen.rs +++ b/crates/parser/src/codegen.rs @@ -107,4 +107,21 @@ mod tests { ], ) } + + #[test] + fn test_create_schema() { + test_get_node_properties( + "create schema if not exists test authorization joe;", + SyntaxKind::CreateSchemaStmt, + vec![ + TokenProperty::from(SyntaxKind::Create), + TokenProperty::from(SyntaxKind::Schema), + TokenProperty::from(SyntaxKind::IfP), + TokenProperty::from(SyntaxKind::Not), + TokenProperty::from(SyntaxKind::Exists), + TokenProperty::from(SyntaxKind::Authorization), + TokenProperty::from("test".to_string()), + ], + ) + } }