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 {
74487448 write ! ( f, "{data_type}" ) ?;
74497449 write ! ( f, " {value}" )
74507450 }
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+ }
74577460 }
74587461 }
74597462}
Original file line number Diff line number Diff line change @@ -2025,8 +2025,12 @@ impl<'a> Parser<'a> {
20252025 })
20262026 }
20272027
2028- // Tries to parse the body of an [ODBC escaping sequence]
2028+ /// Tries to parse the body of an [ODBC escaping sequence]
20292029 /// 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
20302034 fn maybe_parse_odbc_body(&mut self) -> Result<Option<Expr>, ParserError> {
20312035 // Attempt 1: Try to parse it as a function.
20322036 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() {
1629116291 let sql_ts = "SELECT {ts '2025-07-17 14:12:01'}, category_name FROM categories";
1629216292 let _ = all_dialects().verified_stmt(sql_ts);
1629316293}
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