This repository was archived by the owner on Dec 25, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Expand file tree Collapse file tree 3 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -48,10 +48,14 @@ pub enum DataType {
48
48
Boolean ,
49
49
/// Date
50
50
Date ,
51
- /// Time
51
+ /// Time without time zone
52
52
Time ,
53
- /// Timestamp
53
+ /// Time with time zone
54
+ TimeTz ,
55
+ /// Timestamp without time zone
54
56
Timestamp ,
57
+ /// Timestamp with time zone
58
+ TimestampTz ,
55
59
/// Interval
56
60
Interval ,
57
61
/// Regclass used in postgresql serial
@@ -94,7 +98,9 @@ impl fmt::Display for DataType {
94
98
DataType :: Boolean => write ! ( f, "boolean" ) ,
95
99
DataType :: Date => write ! ( f, "date" ) ,
96
100
DataType :: Time => write ! ( f, "time" ) ,
101
+ DataType :: TimeTz => write ! ( f, "time with time zone" ) ,
97
102
DataType :: Timestamp => write ! ( f, "timestamp" ) ,
103
+ DataType :: TimestampTz => write ! ( f, "timestamp with time zone" ) ,
98
104
DataType :: Interval => write ! ( f, "interval" ) ,
99
105
DataType :: Regclass => write ! ( f, "regclass" ) ,
100
106
DataType :: Text => write ! ( f, "text" ) ,
Original file line number Diff line number Diff line change @@ -1541,15 +1541,19 @@ impl Parser {
1541
1541
"UUID" => Ok ( DataType :: Uuid ) ,
1542
1542
"DATE" => Ok ( DataType :: Date ) ,
1543
1543
"TIMESTAMP" => {
1544
- // TBD: we throw away "with/without timezone" information
1545
- if self . parse_keyword ( "WITH" ) || self . parse_keyword ( "WITHOUT" ) {
1544
+ if self . parse_keyword ( "WITH" ) {
1545
+ self . expect_keywords ( & [ "TIME" , "ZONE" ] ) ?;
1546
+ return Ok ( DataType :: TimestampTz )
1547
+ } else if self . parse_keyword ( "WITHOUT" ) {
1546
1548
self . expect_keywords ( & [ "TIME" , "ZONE" ] ) ?;
1547
1549
}
1548
1550
Ok ( DataType :: Timestamp )
1549
1551
}
1550
1552
"TIME" => {
1551
- // TBD: we throw away "with/without timezone" information
1552
- if self . parse_keyword ( "WITH" ) || self . parse_keyword ( "WITHOUT" ) {
1553
+ if self . parse_keyword ( "WITH" ) {
1554
+ self . expect_keywords ( & [ "TIME" , "ZONE" ] ) ?;
1555
+ return Ok ( DataType :: TimeTz )
1556
+ } else if self . parse_keyword ( "WITHOUT" ) {
1553
1557
self . expect_keywords ( & [ "TIME" , "ZONE" ] ) ?;
1554
1558
}
1555
1559
Ok ( DataType :: Time )
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ fn parse_create_table_with_defaults() {
31
31
activebool boolean DEFAULT true NOT NULL,
32
32
create_date date DEFAULT now()::text NOT NULL,
33
33
last_update timestamp without time zone DEFAULT now() NOT NULL,
34
+ last_update_tz timestamp with time zone,
34
35
active integer NOT NULL
35
36
) WITH (fillfactor = 20, user_catalog_table = true, autovacuum_vacuum_threshold = 100)" ;
36
37
match pg_and_generic ( ) . one_statement_parses_to ( sql, "" ) {
@@ -147,6 +148,12 @@ fn parse_create_table_with_defaults() {
147
148
}
148
149
] ,
149
150
} ,
151
+ ColumnDef {
152
+ name: "last_update_tz" . into( ) ,
153
+ data_type: DataType :: TimestampTz ,
154
+ collation: None ,
155
+ options: vec![ ] ,
156
+ } ,
150
157
ColumnDef {
151
158
name: "active" . into( ) ,
152
159
data_type: DataType :: Int ,
You can’t perform that action at this time.
0 commit comments