@@ -52,11 +52,11 @@ pub enum DataType {
5252    /// Date 
5353Date , 
5454    /// Time 
55- Time , 
56-     /// Timestamp [Without Time Zone]  
57- Timestamp , 
58-     /// Timestamp With Time Zone  
59- TimestampTz , 
55+ Time ( TimezoneInfo ) , 
56+     /// Datetime  
57+ Datetime , 
58+     /// Timestamp 
59+ Timestamp ( TimezoneInfo ) , 
6060    /// Interval 
6161Interval , 
6262    /// Regclass used in postgresql serial 
@@ -100,9 +100,9 @@ impl fmt::Display for DataType {
100100            DataType :: Double  => write ! ( f,  "DOUBLE" ) , 
101101            DataType :: Boolean  => write ! ( f,  "BOOLEAN" ) , 
102102            DataType :: Date  => write ! ( f,  "DATE" ) , 
103-             DataType :: Time  => write ! ( f,  "TIME " ) , 
104-             DataType :: Timestamp  => write ! ( f,  "TIMESTAMP"  ) , 
105-             DataType :: TimestampTz  => write ! ( f,  "TIMESTAMPTZ"  ) , 
103+             DataType :: Datetime  => write ! ( f,  "DATETIME " ) , 
104+             DataType :: Time ( timezone_info )  => write ! ( f,  "TIME{}"  ,  timezone_info ) , 
105+             DataType :: Timestamp ( timezone_info )  => write ! ( f,  "TIMESTAMP{}"  ,  timezone_info ) , 
106106            DataType :: Interval  => write ! ( f,  "INTERVAL" ) , 
107107            DataType :: Regclass  => write ! ( f,  "REGCLASS" ) , 
108108            DataType :: Text  => write ! ( f,  "TEXT" ) , 
@@ -125,3 +125,50 @@ fn format_type_with_optional_length(
125125    } 
126126    Ok ( ( ) ) 
127127} 
128+ 
129+ /// Timestamp and Time data types information about TimeZone formatting. 
130+ /// 
131+ /// This is more related to a display information than real differences between each variant. To 
132+ /// guarantee compatibility with the input query we must maintain its exact information. 
133+ #[ derive( Debug ,  Clone ,  PartialEq ,  Eq ,  Hash ) ]  
134+ #[ cfg_attr( feature = "serde" ,  derive( Serialize ,  Deserialize ) ) ]  
135+ pub  enum  TimezoneInfo  { 
136+     /// No information about time zone. E.g., TIMESTAMP 
137+ None , 
138+     /// Temporal type 'WITH TIME ZONE'. E.g., TIMESTAMP WITH TIME ZONE, [standard], [Oracle] 
139+ /// 
140+ /// [standard]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#datetime-type 
141+ /// [Oracle]: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/nlspg/datetime-data-types-and-time-zone-support.html#GUID-3F1C388E-C651-43D5-ADBC-1A49E5C2CA05 
142+ WithTimeZone , 
143+     /// Temporal type 'WITHOUT TIME ZONE'. E.g., TIME WITHOUT TIME ZONE, [standard], [Postgresql] 
144+ /// 
145+ /// [standard]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#datetime-type 
146+ /// [Postgresql]: https://www.postgresql.org/docs/current/datatype-datetime.html 
147+ WithoutTimeZone , 
148+     /// Postgresql specific `WITH TIME ZONE` formatting, for both TIME and TIMESTAMP. E.g., TIMETZ, [Postgresql] 
149+ /// 
150+ /// [Postgresql]: https://www.postgresql.org/docs/current/datatype-datetime.html 
151+ Tz , 
152+ } 
153+ 
154+ impl  fmt:: Display  for  TimezoneInfo  { 
155+     fn  fmt ( & self ,  f :  & mut  fmt:: Formatter < ' _ > )  -> fmt:: Result  { 
156+         match  self  { 
157+             TimezoneInfo :: None  => { 
158+                 write ! ( f,  "" ) 
159+             } 
160+             TimezoneInfo :: WithTimeZone  => { 
161+                 write ! ( f,  " WITH TIME ZONE" ) 
162+             } 
163+             TimezoneInfo :: WithoutTimeZone  => { 
164+                 write ! ( f,  " WITHOUT TIME ZONE" ) 
165+             } 
166+             TimezoneInfo :: Tz  => { 
167+                 // TZ is the only one that is displayed BEFORE the precision, so the datatype display 
168+                 // must be aware of that. Check <https://www.postgresql.org/docs/14/datatype-datetime.html> 
169+                 // for more information 
170+                 write ! ( f,  "TZ" ) 
171+             } 
172+         } 
173+     } 
174+ } 
0 commit comments