diff --git a/prqlc/prqlc/src/sql/gen_expr.rs b/prqlc/prqlc/src/sql/gen_expr.rs index 2fe0786b16f3..973647600a0c 100644 --- a/prqlc/prqlc/src/sql/gen_expr.rs +++ b/prqlc/prqlc/src/sql/gen_expr.rs @@ -432,7 +432,7 @@ fn try_into_between(expr: rq::Expr, ctx: &mut Context) -> Result 3 and x < 5 - if a_l == b_l { + if a_l.kind == b_l.kind { return Ok(Some(sql_ast::Expr::Between { expr: Box::new( translate_operand(a_l, true, 0, Associativity::Both, ctx)? diff --git a/prqlc/prqlc/tests/integration/sql.rs b/prqlc/prqlc/tests/integration/sql.rs index f8dd1d03b042..2c117d3ad585 100644 --- a/prqlc/prqlc/tests/integration/sql.rs +++ b/prqlc/prqlc/tests/integration/sql.rs @@ -1575,6 +1575,21 @@ fn test_ranges() { "); } +#[test] +fn test_between_from_comparison() { + assert_snapshot!((compile(r###" + from t + filter (a >= 5 && a <= 10) + "###).unwrap()), @r" + SELECT + * + FROM + t + WHERE + a BETWEEN 5 AND 10 + "); +} + #[test] fn test_in_values_01() { assert_snapshot!((compile(r#"