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 @@ -7454,12 +7454,15 @@ impl fmt::Display for TypedString {
7454
7454
write ! ( f, "{data_type}" ) ?;
7455
7455
write ! ( f, " {value}" )
7456
7456
}
7457
- true => match data_type {
7458
- DataType :: Date => write ! ( f, "{{d {value}}}" ) ,
7459
- DataType :: Time ( ..) => write ! ( f, "{{t {value}}}" ) ,
7460
- DataType :: Timestamp ( ..) => write ! ( f, "{{ts {value}}}" ) ,
7461
- _ => write ! ( f, "{{? {value}}}" ) ,
7462
- } ,
7457
+ true => {
7458
+ let prefix = match data_type {
7459
+ DataType :: Date => "d" ,
7460
+ DataType :: Time ( ..) => "t" ,
7461
+ DataType :: Timestamp ( ..) => "ts" ,
7462
+ _ => "?" ,
7463
+ } ;
7464
+ write ! ( f, "{{{prefix} {value}}}" )
7465
+ }
7463
7466
}
7464
7467
}
7465
7468
}
Original file line number Diff line number Diff line change @@ -2030,8 +2030,12 @@ impl<'a> Parser<'a> {
2030
2030
})
2031
2031
}
2032
2032
2033
- // Tries to parse the body of an [ODBC escaping sequence]
2033
+ /// Tries to parse the body of an [ODBC escaping sequence]
2034
2034
/// i.e. without the enclosing braces
2035
+ /// Currently implemented:
2036
+ /// Scalar Function Calls
2037
+ /// Date, Time, and Timestamp Literals
2038
+ /// See https://learn.microsoft.com/en-us/sql/odbc/reference/develop-app/escape-sequences-in-odbc?view=sql-server-2017
2035
2039
fn maybe_parse_odbc_body(&mut self) -> Result<Option<Expr>, ParserError> {
2036
2040
// Attempt 1: Try to parse it as a function.
2037
2041
if let Some(expr) = self.maybe_parse_odbc_fn_body()? {
Original file line number Diff line number Diff line change @@ -16324,6 +16324,13 @@ fn test_odbc_time_date_timestamp_support() {
16324
16324
let _ = all_dialects().verified_stmt(sql_ts);
16325
16325
}
16326
16326
16327
+ #[test]
16328
+ #[should_panic]
16329
+ fn test_invalid_odbc_literal_fails() {
16330
+ let sql = "SELECT {tt '14:12:01'} FROM foo";
16331
+ let _ = all_dialects().verified_stmt(sql);
16332
+ }
16333
+
16327
16334
#[test]
16328
16335
fn parse_create_user() {
16329
16336
let create = verified_stmt("CREATE USER u1");
You can’t perform that action at this time.
0 commit comments