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 @@ -7448,12 +7448,15 @@ impl fmt::Display for TypedString {
7448
7448
write ! ( f, "{data_type}" ) ?;
7449
7449
write ! ( f, " {value}" )
7450
7450
}
7451
- true => match data_type {
7452
- DataType :: Date => write ! ( f, "{{d {value}}}" ) ,
7453
- DataType :: Time ( ..) => write ! ( f, "{{t {value}}}" ) ,
7454
- DataType :: Timestamp ( ..) => write ! ( f, "{{ts {value}}}" ) ,
7455
- _ => write ! ( f, "{{? {value}}}" ) ,
7456
- } ,
7451
+ true => {
7452
+ let prefix = match data_type {
7453
+ DataType :: Date => "d" ,
7454
+ DataType :: Time ( ..) => "t" ,
7455
+ DataType :: Timestamp ( ..) => "ts" ,
7456
+ _ => "?" ,
7457
+ } ;
7458
+ write ! ( f, "{{{prefix} {value}}}" )
7459
+ }
7457
7460
}
7458
7461
}
7459
7462
}
Original file line number Diff line number Diff line change @@ -2025,8 +2025,12 @@ impl<'a> Parser<'a> {
2025
2025
})
2026
2026
}
2027
2027
2028
- // Tries to parse the body of an [ODBC escaping sequence]
2028
+ /// Tries to parse the body of an [ODBC escaping sequence]
2029
2029
/// i.e. without the enclosing braces
2030
+ /// Currently implemented:
2031
+ /// Scalar Function Calls
2032
+ /// Date, Time, and Timestamp Literals
2033
+ /// See https://learn.microsoft.com/en-us/sql/odbc/reference/develop-app/escape-sequences-in-odbc?view=sql-server-2017
2030
2034
fn maybe_parse_odbc_body(&mut self) -> Result<Option<Expr>, ParserError> {
2031
2035
// Attempt 1: Try to parse it as a function.
2032
2036
if let Some(expr) = self.maybe_parse_odbc_fn_body()? {
Original file line number Diff line number Diff line change @@ -16291,3 +16291,10 @@ fn test_odbc_time_date_timestamp_support() {
16291
16291
let sql_ts = "SELECT {ts '2025-07-17 14:12:01'}, category_name FROM categories";
16292
16292
let _ = all_dialects().verified_stmt(sql_ts);
16293
16293
}
16294
+
16295
+ #[test]
16296
+ #[should_panic]
16297
+ fn test_invalid_odbc_literal_fails() {
16298
+ let sql = "SELECT {tt '14:12:01'} FROM foo";
16299
+ let _ = all_dialects().verified_stmt(sql);
16300
+ }
You can’t perform that action at this time.
0 commit comments