Skip to content

Commit ddff86e

Browse files
committed
add support for parsing "create domain" statement
1 parent f2fa9a2 commit ddff86e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

crates/codegen/src/get_node_properties.rs

+10
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,16 @@ fn custom_handlers(node: &Node) -> TokenStream {
529529
"TypeCast" => quote! {
530530
tokens.push(TokenProperty::from(Token::Typecast));
531531
},
532+
"CreateDomainStmt" => quote! {
533+
tokens.push(TokenProperty::from(Token::Create));
534+
tokens.push(TokenProperty::from(Token::DomainP));
535+
if n.type_name.is_some() {
536+
tokens.push(TokenProperty::from(Token::As));
537+
}
538+
if n.constraints.len() > 0 {
539+
tokens.push(TokenProperty::from(Token::Check));
540+
}
541+
},
532542
_ => quote! {},
533543
}
534544
}

crates/parser/src/codegen.rs

+15
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,19 @@ mod tests {
9191
],
9292
)
9393
}
94+
95+
#[test]
96+
fn test_create_domain() {
97+
test_get_node_properties(
98+
"create domain us_postal_code as text check (value is not null);",
99+
SyntaxKind::CreateDomainStmt,
100+
vec![
101+
TokenProperty::from(SyntaxKind::Create),
102+
TokenProperty::from(SyntaxKind::DomainP),
103+
TokenProperty::from(SyntaxKind::As),
104+
TokenProperty::from(SyntaxKind::Check),
105+
TokenProperty::from("us_postal_code".to_string()),
106+
],
107+
)
108+
}
94109
}

0 commit comments

Comments
 (0)