Skip to content

Commit

Permalink
chore: bump sqlparser from 0.45.0 to 0.46.0 (#4457)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Roos <[email protected]>
  • Loading branch information
dependabot[bot] and max-sixty authored May 6, 2024
1 parent d0e6da6 commit 820b231
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prqlc/prqlc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ serde = {workspace = true}
serde_json = "1.0.116"
serde_yaml = {version = "0.9.34"}
sqlformat = "0.2.3"
sqlparser = {version = "0.45.0", features = ["serde"]}
sqlparser = {version = "0.46.0", features = ["serde"]}
strum = {version = "0.26.2", features = ["std", "derive"]}
strum_macros = "0.26.2"

Expand Down
27 changes: 18 additions & 9 deletions prqlc/prqlc/src/sql/gen_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use itertools::Itertools;
use regex::Regex;
use sqlparser::ast::{
self as sql_ast, BinaryOperator, DateTimeField, Fetch, Function, FunctionArg, FunctionArgExpr,
ObjectName, OrderByExpr, SelectItem, UnaryOperator, Value, WindowFrameBound, WindowSpec,
FunctionArgumentList, ObjectName, OrderByExpr, SelectItem, UnaryOperator, Value,
WindowFrameBound, WindowSpec,
};
use std::cmp::Ordering;

Expand Down Expand Up @@ -219,23 +220,27 @@ fn process_concat(expr: &Expr, ctx: &mut Context) -> Result<sql_ast::Expr> {
if ctx.dialect.has_concat_function() {
let concat_args = collect_concat_args(expr);

let args = concat_args
let args_list = concat_args
.iter()
.map(|a| {
translate_expr((*a).clone(), ctx)
.map(|x| FunctionArg::Unnamed(FunctionArgExpr::Expr(x.into_ast())))
})
.try_collect()?;

let args = sql_ast::FunctionArguments::List(FunctionArgumentList {
args: args_list,
clauses: vec![],
duplicate_treatment: None,
});

Ok(sql_ast::Expr::Function(Function {
name: ObjectName(vec![sql_ast::Ident::new("CONCAT")]),
args,
over: None,
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
within_group: vec![],
}))
} else {
let concat_args = collect_concat_args(expr);
Expand Down Expand Up @@ -451,15 +456,19 @@ fn translate_datetime_literal_with_sqlite_function(
_ => unreachable!(),
};

let args = sql_ast::FunctionArguments::List(FunctionArgumentList {
args: vec![arg],
clauses: vec![],
duplicate_treatment: None,
});

sql_ast::Expr::Function(Function {
name: ObjectName(vec![sql_ast::Ident::new(func_name)]),
args: vec![arg],
args,
over: None,
distinct: false,
special: false,
order_by: vec![],
filter: None,
null_treatment: None,
within_group: vec![],
})
}

Expand Down
2 changes: 2 additions & 0 deletions prqlc/prqlc/src/sql/gen_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ fn default_select() -> Select {
named_window: vec![],
qualify: None,
value_table_mode: None,
window_before_qualify: false,
connect_by: None,
}
}

Expand Down
4 changes: 2 additions & 2 deletions prqlc/prqlc/tests/integration/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ fn test_interval() {
assert_snapshot!((compile(query).unwrap()), @r###"
SELECT
*,
start + INTERVAL 10 DAY AS first_check_in
"start" + INTERVAL 10 DAY AS first_check_in
FROM
projects
"###);
Expand All @@ -1245,7 +1245,7 @@ fn test_interval() {
assert_snapshot!((compile(query).unwrap()), @r###"
SELECT
*,
start + INTERVAL '10' DAY AS first_check_in
"start" + INTERVAL '10' DAY AS first_check_in
FROM
projects
"###);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ expression: "from projects\nderive first_check_in = start + 10days\n"
---
SELECT
*,
start + INTERVAL 10 DAY AS first_check_in
"start" + INTERVAL 10 DAY AS first_check_in
FROM
projects

0 comments on commit 820b231

Please sign in to comment.