@@ -11695,39 +11695,58 @@ fn parse_projection_trailing_comma() {
1169511695fn parse_create_type() {
1169611696 // Test simple type declaration without AS - verify AST
1169711697 match verified_stmt("CREATE TYPE mytype") {
11698- Statement::CreateType { name, representation } => {
11698+ Statement::CreateType {
11699+ name,
11700+ representation,
11701+ } => {
1169911702 assert_eq!(name.to_string(), "mytype");
1170011703 assert_eq!(representation, UserDefinedTypeRepresentation::None);
1170111704 }
1170211705 _ => unreachable!(),
1170311706 }
1170411707
1170511708 // Test composite type - verify AST structure
11706- match verified_stmt("CREATE TYPE address AS (street VARCHAR(100), city TEXT COLLATE \"en_US\")") {
11707- Statement::CreateType { name, representation } => {
11709+ match verified_stmt("CREATE TYPE address AS (street VARCHAR(100), city TEXT COLLATE \"en_US\")")
11710+ {
11711+ Statement::CreateType {
11712+ name,
11713+ representation,
11714+ } => {
1170811715 assert_eq!(name.to_string(), "address");
1170911716 match representation {
1171011717 UserDefinedTypeRepresentation::Composite { attributes } => {
1171111718 assert_eq!(attributes.len(), 2);
1171211719 assert_eq!(attributes[0].name, Ident::new("street"));
11713- assert_eq!(attributes[0].data_type, DataType::Varchar(Some(CharacterLength::IntegerLength { length: 100, unit: None })));
11720+ assert_eq!(
11721+ attributes[0].data_type,
11722+ DataType::Varchar(Some(CharacterLength::IntegerLength {
11723+ length: 100,
11724+ unit: None
11725+ }))
11726+ );
1171411727 assert_eq!(attributes[0].collation, None);
11715-
11728+
1171611729 assert_eq!(attributes[1].name, Ident::new("city"));
1171711730 assert_eq!(attributes[1].data_type, DataType::Text);
11718- assert_eq!(attributes[1].collation.as_ref().map(|n| n.to_string()), Some("\"en_US\"".to_string()));
11731+ assert_eq!(
11732+ attributes[1].collation.as_ref().map(|n| n.to_string()),
11733+ Some("\"en_US\"".to_string())
11734+ );
1171911735 }
1172011736 _ => unreachable!(),
1172111737 }
1172211738 }
1172311739 _ => unreachable!(),
1172411740 }
11725-
11741+
1172611742 verified_stmt("CREATE TYPE empty AS ()");
1172711743
1172811744 // Test ENUM type - verify AST
1172911745 match verified_stmt("CREATE TYPE mood AS ENUM ('happy', 'sad')") {
11730- Statement::CreateType { name, representation } => {
11746+ Statement::CreateType {
11747+ name,
11748+ representation,
11749+ } => {
1173111750 assert_eq!(name.to_string(), "mood");
1173211751 match representation {
1173311752 UserDefinedTypeRepresentation::Enum { labels } => {
@@ -11743,53 +11762,82 @@ fn parse_create_type() {
1174311762
1174411763 // Test RANGE type - verify AST structure
1174511764 match verified_stmt("CREATE TYPE int4range AS RANGE (SUBTYPE = INTEGER, CANONICAL = fn1)") {
11746- Statement::CreateType { name, representation } => {
11765+ Statement::CreateType {
11766+ name,
11767+ representation,
11768+ } => {
1174711769 assert_eq!(name.to_string(), "int4range");
1174811770 match representation {
1174911771 UserDefinedTypeRepresentation::Range { options } => {
1175011772 assert_eq!(options.len(), 2);
11751- assert!(matches!(options[0], UserDefinedTypeRangeOption::Subtype(DataType::Integer(_))));
11752- assert!(matches!(options[1], UserDefinedTypeRangeOption::Canonical(_)));
11773+ assert!(matches!(
11774+ options[0],
11775+ UserDefinedTypeRangeOption::Subtype(DataType::Integer(_))
11776+ ));
11777+ assert!(matches!(
11778+ options[1],
11779+ UserDefinedTypeRangeOption::Canonical(_)
11780+ ));
1175311781 }
1175411782 _ => unreachable!(),
1175511783 }
1175611784 }
1175711785 _ => unreachable!(),
1175811786 }
11759-
11787+
1176011788 verified_stmt("CREATE TYPE textrange AS RANGE (SUBTYPE = TEXT, COLLATION = \"en_US\", MULTIRANGE_TYPE_NAME = textmultirange)");
1176111789
1176211790 // Test SQL definition type - verify AST
11763- match verified_stmt("CREATE TYPE mytype (INPUT = in_fn, OUTPUT = out_fn, INTERNALLENGTH = 16, PASSEDBYVALUE)") {
11764- Statement::CreateType { name, representation } => {
11791+ match verified_stmt(
11792+ "CREATE TYPE mytype (INPUT = in_fn, OUTPUT = out_fn, INTERNALLENGTH = 16, PASSEDBYVALUE)",
11793+ ) {
11794+ Statement::CreateType {
11795+ name,
11796+ representation,
11797+ } => {
1176511798 assert_eq!(name.to_string(), "mytype");
1176611799 match representation {
1176711800 UserDefinedTypeRepresentation::SqlDefinition { options } => {
1176811801 assert_eq!(options.len(), 4);
11769- assert!(matches!(options[0], UserDefinedTypeSqlDefinitionOption::Input(_)));
11770- assert!(matches!(options[1], UserDefinedTypeSqlDefinitionOption::Output(_)));
1177111802 assert!(matches!(
11772- options[2],
11773- UserDefinedTypeSqlDefinitionOption::InternalLength(UserDefinedTypeInternalLength::Fixed(16))
11803+ options[0],
11804+ UserDefinedTypeSqlDefinitionOption::Input(_)
11805+ ));
11806+ assert!(matches!(
11807+ options[1],
11808+ UserDefinedTypeSqlDefinitionOption::Output(_)
11809+ ));
11810+ assert!(matches!(
11811+ options[2],
11812+ UserDefinedTypeSqlDefinitionOption::InternalLength(
11813+ UserDefinedTypeInternalLength::Fixed(16)
11814+ )
11815+ ));
11816+ assert!(matches!(
11817+ options[3],
11818+ UserDefinedTypeSqlDefinitionOption::PassedByValue
1177411819 ));
11775- assert!(matches!(options[3], UserDefinedTypeSqlDefinitionOption::PassedByValue));
1177611820 }
1177711821 _ => unreachable!(),
1177811822 }
1177911823 }
1178011824 _ => unreachable!(),
1178111825 }
11782-
11826+
1178311827 verified_stmt("CREATE TYPE mytype (INPUT = in_fn, OUTPUT = out_fn, INTERNALLENGTH = VARIABLE, STORAGE = extended)");
11784-
11828+
1178511829 // Test all storage variants
1178611830 for storage in ["plain", "external", "extended", "main"] {
11787- verified_stmt(&format!("CREATE TYPE t (INPUT = f_in, OUTPUT = f_out, STORAGE = {storage})"));
11831+ verified_stmt(&format!(
11832+ "CREATE TYPE t (INPUT = f_in, OUTPUT = f_out, STORAGE = {storage})"
11833+ ));
1178811834 }
1178911835
1179011836 // Test all alignment variants
1179111837 for align in ["char", "int2", "int4", "double"] {
11792- verified_stmt(&format!("CREATE TYPE t (INPUT = f_in, OUTPUT = f_out, ALIGNMENT = {align})"));
11838+ verified_stmt(&format!(
11839+ "CREATE TYPE t (INPUT = f_in, OUTPUT = f_out, ALIGNMENT = {align})"
11840+ ));
1179311841 }
1179411842
1179511843 // Test additional function options (PostgreSQL-specific due to ANALYZE keyword)
0 commit comments