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 @@ -7422,12 +7422,15 @@ impl fmt::Display for TypedString {
7422
7422
write ! ( f, "{data_type}" ) ?;
7423
7423
write ! ( f, " {value}" )
7424
7424
}
7425
- true => match data_type {
7426
- DataType :: Date => write ! ( f, "{{d {value}}}" ) ,
7427
- DataType :: Time ( ..) => write ! ( f, "{{t {value}}}" ) ,
7428
- DataType :: Timestamp ( ..) => write ! ( f, "{{ts {value}}}" ) ,
7429
- _ => write ! ( f, "{{? {value}}}" ) ,
7430
- } ,
7425
+ true => {
7426
+ let prefix = match data_type {
7427
+ DataType :: Date => "d" ,
7428
+ DataType :: Time ( ..) => "t" ,
7429
+ DataType :: Timestamp ( ..) => "ts" ,
7430
+ _ => "?" ,
7431
+ } ;
7432
+ write ! ( f, "{{{prefix} {value}}}" )
7433
+ }
7431
7434
}
7432
7435
}
7433
7436
}
Original file line number Diff line number Diff line change @@ -2018,8 +2018,12 @@ impl<'a> Parser<'a> {
2018
2018
})
2019
2019
}
2020
2020
2021
- // Tries to parse the body of an [ODBC escaping sequence]
2021
+ /// Tries to parse the body of an [ODBC escaping sequence]
2022
2022
/// i.e. without the enclosing braces
2023
+ /// Currently implemented:
2024
+ /// Scalar Function Calls
2025
+ /// Date, Time, and Timestamp Literals
2026
+ /// See https://learn.microsoft.com/en-us/sql/odbc/reference/develop-app/escape-sequences-in-odbc?view=sql-server-2017
2023
2027
fn maybe_parse_odbc_body(&mut self) -> Result<Option<Expr>, ParserError> {
2024
2028
// Attempt 1: Try to parse it as a function.
2025
2029
if let Some(expr) = self.maybe_parse_odbc_fn_body()? {
Original file line number Diff line number Diff line change @@ -16209,3 +16209,10 @@ fn test_odbc_time_date_timestamp_support() {
16209
16209
let sql_ts = "SELECT {ts '2025-07-17 14:12:01'}, category_name FROM categories";
16210
16210
let _ = all_dialects().verified_stmt(sql_ts);
16211
16211
}
16212
+
16213
+ #[test]
16214
+ #[should_panic]
16215
+ fn test_invalid_odbc_literal_fails() {
16216
+ let sql = "SELECT {tt '14:12:01'} FROM foo";
16217
+ let _ = all_dialects().verified_stmt(sql);
16218
+ }
You can’t perform that action at this time.
0 commit comments