mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-15 16:29:02 +00:00
Support for MSSQL CONVERT
styles (#1219)
This commit is contained in:
parent
6fcf8c9abe
commit
0606024353
3 changed files with 47 additions and 0 deletions
|
@ -567,6 +567,10 @@ pub enum Expr {
|
|||
charset: Option<ObjectName>,
|
||||
/// whether the target comes before the expr (MSSQL syntax)
|
||||
target_before_value: bool,
|
||||
/// How to translate the expression.
|
||||
///
|
||||
/// [MSSQL]: https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16#style
|
||||
styles: Vec<Expr>,
|
||||
},
|
||||
/// `CAST` an expression to a different data type e.g. `CAST(foo AS VARCHAR(123))`
|
||||
Cast {
|
||||
|
@ -979,6 +983,7 @@ impl fmt::Display for Expr {
|
|||
target_before_value,
|
||||
data_type,
|
||||
charset,
|
||||
styles,
|
||||
} => {
|
||||
write!(f, "CONVERT(")?;
|
||||
if let Some(data_type) = data_type {
|
||||
|
@ -994,6 +999,9 @@ impl fmt::Display for Expr {
|
|||
} else {
|
||||
write!(f, "{expr}") // This should never happen
|
||||
}?;
|
||||
if !styles.is_empty() {
|
||||
write!(f, ", {}", display_comma_separated(styles))?;
|
||||
}
|
||||
write!(f, ")")
|
||||
}
|
||||
Expr::Cast {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue