Replace Method and CompositeAccess with CompoundFieldAccess (#1716)

This commit is contained in:
Ifeanyi Ubah 2025-02-19 18:49:42 +01:00 committed by GitHub
parent c75a992621
commit 3e90a18f6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 348 additions and 264 deletions

View file

@ -661,11 +661,6 @@ pub enum Expr {
/// The path to the data to extract.
path: JsonPath,
},
/// CompositeAccess eg: SELECT foo(bar).z, (information_schema._pg_expandarray(array['i','i'])).n
CompositeAccess {
expr: Box<Expr>,
key: Ident,
},
/// `IS FALSE` operator
IsFalse(Box<Expr>),
/// `IS NOT FALSE` operator
@ -915,23 +910,6 @@ pub enum Expr {
},
/// Scalar function call e.g. `LEFT(foo, 5)`
Function(Function),
/// Arbitrary expr method call
///
/// Syntax:
///
/// `<arbitrary-expr>.<function-call>.<function-call-expr>...`
///
/// > `arbitrary-expr` can be any expression including a function call.
///
/// Example:
///
/// ```sql
/// SELECT (SELECT ',' + name FROM sys.objects FOR XML PATH(''), TYPE).value('.','NVARCHAR(MAX)')
/// SELECT CONVERT(XML,'<Book>abc</Book>').value('.','NVARCHAR(MAX)').value('.','NVARCHAR(MAX)')
/// ```
///
/// (mssql): <https://learn.microsoft.com/en-us/sql/t-sql/xml/xml-data-type-methods?view=sql-server-ver16>
Method(Method),
/// `CASE [<operand>] WHEN <condition> THEN <result> ... [ELSE <result>] END`
///
/// Note we only recognize a complete single expression as `<condition>`,
@ -1631,7 +1609,6 @@ impl fmt::Display for Expr {
write!(f, " {value}")
}
Expr::Function(fun) => write!(f, "{fun}"),
Expr::Method(method) => write!(f, "{method}"),
Expr::Case {
operand,
conditions,
@ -1789,9 +1766,6 @@ impl fmt::Display for Expr {
Expr::JsonAccess { value, path } => {
write!(f, "{value}{path}")
}
Expr::CompositeAccess { expr, key } => {
write!(f, "{expr}.{key}")
}
Expr::AtTimeZone {
timestamp,
time_zone,