@@ -43,6 +43,7 @@ pub enum Value {
4343 /// so the user will have to reject intervals like `HOUR TO YEAR`.
4444 Interval {
4545 value : String ,
46+ value_quoting : Option < char > ,
4647 leading_field : Option < DateTimeField > ,
4748 leading_precision : Option < u64 > ,
4849 last_field : Option < DateTimeField > ,
@@ -66,6 +67,7 @@ impl fmt::Display for Value {
6667 Value :: Boolean ( v) => write ! ( f, "{}" , v) ,
6768 Value :: Interval {
6869 value,
70+ value_quoting,
6971 leading_field : Some ( DateTimeField :: Second ) ,
7072 leading_precision : Some ( leading_precision) ,
7173 last_field,
@@ -74,22 +76,32 @@ impl fmt::Display for Value {
7476 // When the leading field is SECOND, the parser guarantees that
7577 // the last field is None.
7678 assert ! ( last_field. is_none( ) ) ;
79+ write ! ( f, "INTERVAL " ) ?;
80+ if let Some ( ch) = value_quoting {
81+ write ! ( f, "{}{}{}" , ch, escape_single_quote_string( value) , ch) ?;
82+ } else {
83+ write ! ( f, "{}" , value) ?;
84+ }
7785 write ! (
7886 f,
79- "INTERVAL '{}' SECOND ({}, {})" ,
80- escape_single_quote_string( value) ,
81- leading_precision,
82- fractional_seconds_precision
87+ " SECOND ({}, {})" ,
88+ leading_precision, fractional_seconds_precision
8389 )
8490 }
8591 Value :: Interval {
8692 value,
93+ value_quoting,
8794 leading_field,
8895 leading_precision,
8996 last_field,
9097 fractional_seconds_precision,
9198 } => {
92- write ! ( f, "INTERVAL '{}'" , escape_single_quote_string( value) ) ?;
99+ write ! ( f, "INTERVAL " ) ?;
100+ if let Some ( ch) = value_quoting {
101+ write ! ( f, "{}{}{}" , ch, escape_single_quote_string( value) , ch) ?;
102+ } else {
103+ write ! ( f, "{}" , value) ?;
104+ }
93105 if let Some ( leading_field) = leading_field {
94106 write ! ( f, " {}" , leading_field) ?;
95107 }
0 commit comments