Skip to content

Commit

Permalink
feat: extend support for type name
Browse files Browse the repository at this point in the history
  • Loading branch information
cvng committed Jan 2, 2024
1 parent 1809ea0 commit 593b83f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions crates/codegen/src/get_node_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,37 @@ fn custom_handlers(node: &Node) -> TokenStream {
tokens.push(TokenProperty::from(Token::Function));
}
},
"TypeName" => quote! {
let names = n.names
.iter()
.filter_map(|n| if let Some(NodeEnum::String(s)) = &n.node { Some(s.sval.clone()) } else { None })
.collect::<Vec<_>>();

if names.len() == 2 && names[0] == "pg_catalog" {
match names[1].as_str() {
"interval" => {
tokens.push(TokenProperty::from(Token::To)); //
tokens.push(TokenProperty::from(Token::SecondP)); //
},
"timestamptz" => {
tokens.push(TokenProperty::from(Token::With));
tokens.push(TokenProperty::from(Token::Time));
tokens.push(TokenProperty::from(Token::Zone));
}
"time" => {
tokens.push(TokenProperty::from(Token::Time));
},
"timetz" => {
tokens.push(TokenProperty::from(Token::Time));
tokens.push(TokenProperty::from(Token::With));
tokens.push(TokenProperty::from(Token::Time));
tokens.push(TokenProperty::from(Token::Zone));
tokens.push(TokenProperty::from(Token::Not)); //
}
_ => {}
}
}
},
_ => quote! {},
}
}
Expand Down

0 comments on commit 593b83f

Please sign in to comment.