@@ -832,7 +832,7 @@ impl TryFromDialect<sqlparser::ast::Expr> for Expr {
832
832
field,
833
833
syntax : _, // We only support FROM
834
834
expr,
835
- } => Ok ( Self :: Call ( crate :: ast :: FunctionExpr :: Extract {
835
+ } => Ok ( Self :: Call ( FunctionExpr :: Extract {
836
836
field : field. into ( ) ,
837
837
expr : expr. try_into_dialect ( dialect) ?,
838
838
} ) ) ,
@@ -1048,7 +1048,7 @@ impl FromDialect<sqlparser::ast::Ident> for Expr {
1048
1048
1049
1049
/// Convert a function call into an expression.
1050
1050
///
1051
- /// We don't turn every function into a [`crate::ast:: FunctionExpr`], beacuse we have some special
1051
+ /// We don't turn every function into a [`FunctionExpr`], beacuse we have some special
1052
1052
/// cases that turn into other kinds of expressions, such as `DATE(x)` into `CAST(x AS DATE)`.
1053
1053
impl TryFromDialect < sqlparser:: ast:: Function > for Expr {
1054
1054
fn try_from_dialect (
@@ -1071,7 +1071,7 @@ impl TryFromDialect<sqlparser::ast::Function> for Expr {
1071
1071
FunctionArguments :: List ( FunctionArgumentList { args, .. } )
1072
1072
if args == vec ! [ FunctionArg :: Unnamed ( FunctionArgExpr :: Wildcard ) ] =>
1073
1073
{
1074
- return Ok ( Self :: Call ( crate :: ast :: FunctionExpr :: CountStar ) ) ;
1074
+ return Ok ( Self :: Call ( FunctionExpr :: CountStar ) ) ;
1075
1075
}
1076
1076
_ => { }
1077
1077
}
@@ -1100,22 +1100,22 @@ impl TryFromDialect<sqlparser::ast::Function> for Expr {
1100
1100
} ;
1101
1101
Ok ( match name_lowercase. as_str ( ) {
1102
1102
// TODO: fix this unnecessary cloning
1103
- "avg" => Self :: Call ( crate :: ast :: FunctionExpr :: Avg {
1103
+ "avg" => Self :: Call ( FunctionExpr :: Avg {
1104
1104
expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1105
1105
distinct,
1106
1106
} ) ,
1107
1107
// TODO: check for `count(*)` which we have a separate enum variant for
1108
- "count" => Self :: Call ( crate :: ast :: FunctionExpr :: Count {
1108
+ "count" => Self :: Call ( FunctionExpr :: Count {
1109
1109
expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1110
1110
distinct,
1111
1111
} ) ,
1112
- "group_concat" => Self :: Call ( crate :: ast :: FunctionExpr :: GroupConcat {
1112
+ "group_concat" => Self :: Call ( FunctionExpr :: GroupConcat {
1113
1113
expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1114
1114
separator,
1115
1115
} ) ,
1116
- "max" => Self :: Call ( crate :: ast :: FunctionExpr :: Max ( Box :: new ( exprs[ 0 ] . clone ( ) ) ) ) ,
1117
- "min" => Self :: Call ( crate :: ast :: FunctionExpr :: Min ( Box :: new ( exprs[ 0 ] . clone ( ) ) ) ) ,
1118
- "sum" => Self :: Call ( crate :: ast :: FunctionExpr :: Sum {
1116
+ "max" => Self :: Call ( FunctionExpr :: Max ( Box :: new ( exprs[ 0 ] . clone ( ) ) ) ) ,
1117
+ "min" => Self :: Call ( FunctionExpr :: Min ( Box :: new ( exprs[ 0 ] . clone ( ) ) ) ) ,
1118
+ "sum" => Self :: Call ( FunctionExpr :: Sum {
1119
1119
expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1120
1120
distinct,
1121
1121
} ) ,
@@ -1125,7 +1125,18 @@ impl TryFromDialect<sqlparser::ast::Function> for Expr {
1125
1125
postgres_style : false ,
1126
1126
} ,
1127
1127
"extract" | "substring" => todo ! ( ) ,
1128
- _ => Self :: Call ( crate :: ast:: FunctionExpr :: Call {
1128
+ // TODO(mvzink): support COLLATE for upper and lower. nom-sql doesn't seem to parse
1129
+ // collation here, and in the case of sqlparser-rs we would have to pull it out of the
1130
+ // inner expression
1131
+ "lower" => Self :: Call ( FunctionExpr :: Lower {
1132
+ expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1133
+ collation : None ,
1134
+ } ) ,
1135
+ "upper" => Self :: Call ( FunctionExpr :: Upper {
1136
+ expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1137
+ collation : None ,
1138
+ } ) ,
1139
+ _ => Self :: Call ( FunctionExpr :: Call {
1129
1140
name : name. into_dialect ( dialect) ,
1130
1141
arguments : exprs,
1131
1142
} ) ,
0 commit comments