@@ -715,3 +715,43 @@ impl fmt::Display for ReferentialAction {
715715 } )
716716 }
717717}
718+
719+ /// SQL user defined type definition
720+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
721+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
722+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
723+ pub enum UserDefinedTypeRepresentation {
724+ Composite {
725+ attributes : Vec < UserDefinedTypeCompositeAttributeDef > ,
726+ } ,
727+ }
728+
729+ impl fmt:: Display for UserDefinedTypeRepresentation {
730+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
731+ match self {
732+ UserDefinedTypeRepresentation :: Composite { attributes } => {
733+ write ! ( f, "({})" , display_comma_separated( attributes) )
734+ }
735+ }
736+ }
737+ }
738+
739+ /// SQL user defined type attribute definition
740+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
741+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
742+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
743+ pub struct UserDefinedTypeCompositeAttributeDef {
744+ pub name : Ident ,
745+ pub data_type : DataType ,
746+ pub collation : Option < ObjectName > ,
747+ }
748+
749+ impl fmt:: Display for UserDefinedTypeCompositeAttributeDef {
750+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
751+ write ! ( f, "{} {}" , self . name, self . data_type) ?;
752+ if let Some ( collation) = & self . collation {
753+ write ! ( f, " COLLATE {collation}" ) ?;
754+ }
755+ Ok ( ( ) )
756+ }
757+ }
0 commit comments