File tree Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Expand file tree Collapse file tree 3 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -7475,12 +7475,15 @@ impl fmt::Display for TypedString {
7475
7475
write ! ( f, "{data_type}" ) ?;
7476
7476
write ! ( f, " {value}" )
7477
7477
}
7478
- true => match data_type {
7479
- DataType :: Date => write ! ( f, "{{d {value}}}" ) ,
7480
- DataType :: Time ( ..) => write ! ( f, "{{t {value}}}" ) ,
7481
- DataType :: Timestamp ( ..) => write ! ( f, "{{ts {value}}}" ) ,
7482
- _ => write ! ( f, "{{? {value}}}" ) ,
7483
- } ,
7478
+ true => {
7479
+ let prefix = match data_type {
7480
+ DataType :: Date => "d" ,
7481
+ DataType :: Time ( ..) => "t" ,
7482
+ DataType :: Timestamp ( ..) => "ts" ,
7483
+ _ => "?" ,
7484
+ } ;
7485
+ write ! ( f, "{{{prefix} {value}}}" )
7486
+ }
7484
7487
}
7485
7488
}
7486
7489
}
Original file line number Diff line number Diff line change @@ -2034,8 +2034,12 @@ impl<'a> Parser<'a> {
2034
2034
})
2035
2035
}
2036
2036
2037
- // Tries to parse the body of an [ODBC escaping sequence]
2037
+ /// Tries to parse the body of an [ODBC escaping sequence]
2038
2038
/// i.e. without the enclosing braces
2039
+ /// Currently implemented:
2040
+ /// Scalar Function Calls
2041
+ /// Date, Time, and Timestamp Literals
2042
+ /// See https://learn.microsoft.com/en-us/sql/odbc/reference/develop-app/escape-sequences-in-odbc?view=sql-server-2017
2039
2043
fn maybe_parse_odbc_body(&mut self) -> Result<Option<Expr>, ParserError> {
2040
2044
// Attempt 1: Try to parse it as a function.
2041
2045
if let Some(expr) = self.maybe_parse_odbc_fn_body()? {
Original file line number Diff line number Diff line change @@ -16326,6 +16326,13 @@ fn test_odbc_time_date_timestamp_support() {
16326
16326
let _ = all_dialects().verified_stmt(sql_ts);
16327
16327
}
16328
16328
16329
+ #[test]
16330
+ #[should_panic]
16331
+ fn test_invalid_odbc_literal_fails() {
16332
+ let sql = "SELECT {tt '14:12:01'} FROM foo";
16333
+ let _ = all_dialects().verified_stmt(sql);
16334
+ }
16335
+
16329
16336
#[test]
16330
16337
fn parse_create_user() {
16331
16338
let create = verified_stmt("CREATE USER u1");
You can’t perform that action at this time.
0 commit comments