Skip to content

Commit

Permalink
feat: support "create schema"
Browse files Browse the repository at this point in the history
  • Loading branch information
cvng committed Dec 12, 2023
1 parent 00fd160 commit b527f75
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/codegen/src/get_node_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {},
}
}
Expand Down
17 changes: 17 additions & 0 deletions crates/parser/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
],
)
}
}

0 comments on commit b527f75

Please sign in to comment.