Skip to content

Commit b527f75

Browse files
committed
feat: support "create schema"
1 parent 00fd160 commit b527f75

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
@@ -536,6 +536,18 @@ fn custom_handlers(node: &Node) -> TokenStream {
536536
tokens.push(TokenProperty::from(Token::As));
537537
}
538538
},
539+
"CreateSchemaStmt" => quote! {
540+
tokens.push(TokenProperty::from(Token::Create));
541+
tokens.push(TokenProperty::from(Token::Schema));
542+
if n.if_not_exists {
543+
tokens.push(TokenProperty::from(Token::IfP));
544+
tokens.push(TokenProperty::from(Token::Not));
545+
tokens.push(TokenProperty::from(Token::Exists));
546+
}
547+
if n.authrole.is_some() {
548+
tokens.push(TokenProperty::from(Token::Authorization));
549+
}
550+
},
539551
_ => quote! {},
540552
}
541553
}

crates/parser/src/codegen.rs

+17
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,21 @@ mod tests {
107107
],
108108
)
109109
}
110+
111+
#[test]
112+
fn test_create_schema() {
113+
test_get_node_properties(
114+
"create schema if not exists test authorization joe;",
115+
SyntaxKind::CreateSchemaStmt,
116+
vec![
117+
TokenProperty::from(SyntaxKind::Create),
118+
TokenProperty::from(SyntaxKind::Schema),
119+
TokenProperty::from(SyntaxKind::IfP),
120+
TokenProperty::from(SyntaxKind::Not),
121+
TokenProperty::from(SyntaxKind::Exists),
122+
TokenProperty::from(SyntaxKind::Authorization),
123+
TokenProperty::from("test".to_string()),
124+
],
125+
)
126+
}
110127
}

0 commit comments

Comments
 (0)