Add PostgreSQL specfic "CREATE TYPE t AS ENUM (...)" support. (#1460)

This commit is contained in:
David Caldwell 2024-10-21 11:44:38 -07:00 committed by GitHub
parent 45c5d69b22
commit a8432b57db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 68 additions and 1 deletions

View file

@ -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!(),
}
}