Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

etgarperets
Copy link
Contributor

…timestamp literals. For this I modified TypedString by adding uses_odbc_syntax flag.

…timestamp literals. For this I modified TypedString by adding uses_odbc_syntax flag.
Copy link
Contributor

@iffyio iffyio left a 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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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]
Copy link
Contributor

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";
Copy link
Contributor

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

Comment on lines +7425 to +7430
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}}}"),
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

@iffyio iffyio changed the title SGA-11414 Added support for odbc escape sequencing for time date and … Add ODBC escape syntax support for time expressions Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants