-
Notifications
You must be signed in to change notification settings - Fork 625
Add ODBC escape syntax support for time expressions #1953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "\u201Codbc-time-date-timestamp-support\u201D"
Add ODBC escape syntax support for time expressions #1953
Conversation
…timestamp literals. For this I modified TypedString by adding uses_odbc_syntax flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @etgarperets! The changes look good to me overall, left some minor comments
@@ -2016,6 +2018,46 @@ impl<'a> Parser<'a> { | |||
}) | |||
} | |||
|
|||
// Tries to parse the body of an [ODBC escaping sequence] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Tries to parse the body of an [ODBC escaping sequence] | |
/// Tries to parse the body of an [ODBC escaping sequence] |
@@ -2016,6 +2018,46 @@ impl<'a> Parser<'a> { | |||
}) | |||
} | |||
|
|||
// Tries to parse the body of an [ODBC escaping sequence] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ODBC escaping sequence]
Can we include a doc link referencing this part of the comment?
|
||
#[test] | ||
fn test_odbc_time_date_timestamp_support() { | ||
let sql_d = "SELECT {d '2025-07-17'}, category_name FROM categories"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we include a negative test for an expression that doesn't use the expected character? e.g. SELECT {tt '14:12:01'} FROM foo
true => match data_type { | ||
DataType::Date => write!(f, "{{d {value}}}"), | ||
DataType::Time(..) => write!(f, "{{t {value}}}"), | ||
DataType::Timestamp(..) => write!(f, "{{ts {value}}}"), | ||
_ => write!(f, "{{? {value}}}"), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true => match data_type { | |
DataType::Date => write!(f, "{{d {value}}}"), | |
DataType::Time(..) => write!(f, "{{t {value}}}"), | |
DataType::Timestamp(..) => write!(f, "{{ts {value}}}"), | |
_ => write!(f, "{{? {value}}}"), | |
}, | |
true => { | |
let dt = match data_type { | |
DataType::Date => "d", | |
DataType::Time(..) => "t" | |
DataType::Timestamp(..) => "ts", | |
}; | |
write!("{{ {dt} }}") | |
}, |
I think this branch could be simplified to something like above?
…timestamp literals. For this I modified TypedString by adding uses_odbc_syntax flag.