mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-10 02:14:58 +00:00
Add PostgreSQL specfic "CREATE TYPE t AS ENUM (...)" support. (#1460)
This commit is contained in:
parent
45c5d69b22
commit
a8432b57db
3 changed files with 68 additions and 1 deletions
|
@ -5128,3 +5128,32 @@ fn arrow_cast_precedence() {
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_type_as_enum() {
|
||||
let statement = pg().one_statement_parses_to(
|
||||
r#"CREATE TYPE public.my_type AS ENUM (
|
||||
'label1',
|
||||
'label2',
|
||||
'label3',
|
||||
'label4'
|
||||
);"#,
|
||||
"CREATE TYPE public.my_type AS ENUM ('label1', 'label2', 'label3', 'label4')",
|
||||
);
|
||||
match statement {
|
||||
Statement::CreateType {
|
||||
name,
|
||||
representation: UserDefinedTypeRepresentation::Enum { labels },
|
||||
} => {
|
||||
assert_eq!("public.my_type", name.to_string());
|
||||
assert_eq!(
|
||||
vec!["label1", "label2", "label3", "label4"]
|
||||
.into_iter()
|
||||
.map(|l| Ident::with_quote('\'', l))
|
||||
.collect::<Vec<Ident>>(),
|
||||
labels
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue