Skip to content

Commit 9c6ff9a

Browse files
committed
feat: support "create schema"
1 parent 761d11a commit 9c6ff9a

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
@@ -105,4 +105,21 @@ mod tests {
105105
],
106106
)
107107
}
108+
109+
#[test]
110+
fn test_create_schema() {
111+
test_get_node_properties(
112+
"create schema if not exists test authorization joe;",
113+
SyntaxKind::CreateSchemaStmt,
114+
vec![
115+
TokenProperty::from(SyntaxKind::Create),
116+
TokenProperty::from(SyntaxKind::Schema),
117+
TokenProperty::from(SyntaxKind::IfP),
118+
TokenProperty::from(SyntaxKind::Not),
119+
TokenProperty::from(SyntaxKind::Exists),
120+
TokenProperty::from(SyntaxKind::Authorization),
121+
TokenProperty::from("test".to_string()),
122+
],
123+
)
124+
}
108125
}

0 commit comments

Comments
 (0)