@@ -866,7 +866,7 @@ impl TryFromDialect<sqlparser::ast::Expr> for Expr {
866
866
field,
867
867
syntax : _, // We only support FROM
868
868
expr,
869
- } => Ok ( Self :: Call ( crate :: ast :: FunctionExpr :: Extract {
869
+ } => Ok ( Self :: Call ( FunctionExpr :: Extract {
870
870
field : field. into ( ) ,
871
871
expr : expr. try_into_dialect ( dialect) ?,
872
872
} ) ) ,
@@ -1078,7 +1078,7 @@ impl FromDialect<sqlparser::ast::Ident> for Expr {
1078
1078
1079
1079
/// Convert a function call into an expression.
1080
1080
///
1081
- /// We don't turn every function into a [`crate::ast:: FunctionExpr`], beacuse we have some special
1081
+ /// We don't turn every function into a [`FunctionExpr`], beacuse we have some special
1082
1082
/// cases that turn into other kinds of expressions, such as `DATE(x)` into `CAST(x AS DATE)`.
1083
1083
impl TryFromDialect < sqlparser:: ast:: Function > for Expr {
1084
1084
fn try_from_dialect (
@@ -1101,7 +1101,7 @@ impl TryFromDialect<sqlparser::ast::Function> for Expr {
1101
1101
FunctionArguments :: List ( FunctionArgumentList { args, .. } )
1102
1102
if args == vec ! [ FunctionArg :: Unnamed ( FunctionArgExpr :: Wildcard ) ] =>
1103
1103
{
1104
- return Ok ( Self :: Call ( crate :: ast :: FunctionExpr :: CountStar ) ) ;
1104
+ return Ok ( Self :: Call ( FunctionExpr :: CountStar ) ) ;
1105
1105
}
1106
1106
_ => { }
1107
1107
}
@@ -1128,22 +1128,22 @@ impl TryFromDialect<sqlparser::ast::Function> for Expr {
1128
1128
} ;
1129
1129
Ok ( match name_lowercase. as_str ( ) {
1130
1130
// TODO: fix this unnecessary cloning
1131
- "avg" => Self :: Call ( crate :: ast :: FunctionExpr :: Avg {
1131
+ "avg" => Self :: Call ( FunctionExpr :: Avg {
1132
1132
expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1133
1133
distinct,
1134
1134
} ) ,
1135
1135
// TODO: check for `count(*)` which we have a separate enum variant for
1136
- "count" => Self :: Call ( crate :: ast :: FunctionExpr :: Count {
1136
+ "count" => Self :: Call ( FunctionExpr :: Count {
1137
1137
expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1138
1138
distinct,
1139
1139
} ) ,
1140
- "group_concat" => Self :: Call ( crate :: ast :: FunctionExpr :: GroupConcat {
1140
+ "group_concat" => Self :: Call ( FunctionExpr :: GroupConcat {
1141
1141
expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1142
1142
separator,
1143
1143
} ) ,
1144
- "max" => Self :: Call ( crate :: ast :: FunctionExpr :: Max ( Box :: new ( exprs[ 0 ] . clone ( ) ) ) ) ,
1145
- "min" => Self :: Call ( crate :: ast :: FunctionExpr :: Min ( Box :: new ( exprs[ 0 ] . clone ( ) ) ) ) ,
1146
- "sum" => Self :: Call ( crate :: ast :: FunctionExpr :: Sum {
1144
+ "max" => Self :: Call ( FunctionExpr :: Max ( Box :: new ( exprs[ 0 ] . clone ( ) ) ) ) ,
1145
+ "min" => Self :: Call ( FunctionExpr :: Min ( Box :: new ( exprs[ 0 ] . clone ( ) ) ) ) ,
1146
+ "sum" => Self :: Call ( FunctionExpr :: Sum {
1147
1147
expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1148
1148
distinct,
1149
1149
} ) ,
@@ -1153,7 +1153,18 @@ impl TryFromDialect<sqlparser::ast::Function> for Expr {
1153
1153
postgres_style : false ,
1154
1154
} ,
1155
1155
"extract" | "substring" => todo ! ( ) ,
1156
- _ => Self :: Call ( crate :: ast:: FunctionExpr :: Call {
1156
+ // TODO(mvzink): support COLLATE for upper and lower. nom-sql doesn't seem to parse
1157
+ // collation here, and in the case of sqlparser-rs we would have to pull it out of the
1158
+ // inner expression
1159
+ "lower" => Self :: Call ( FunctionExpr :: Lower {
1160
+ expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1161
+ collation : None ,
1162
+ } ) ,
1163
+ "upper" => Self :: Call ( FunctionExpr :: Upper {
1164
+ expr : Box :: new ( exprs[ 0 ] . clone ( ) ) ,
1165
+ collation : None ,
1166
+ } ) ,
1167
+ _ => Self :: Call ( FunctionExpr :: Call {
1157
1168
name : name. into_dialect ( dialect) ,
1158
1169
arguments : exprs,
1159
1170
} ) ,
0 commit comments