From dc3d3a492a98d007ce53435402db0006a49bbaa9 Mon Sep 17 00:00:00 2001 From: rjhallsted Date: Thu, 12 Sep 2024 12:03:27 -0700 Subject: [PATCH] Fix register positions of binary expression arguments to fix where-like-fn case --- core/translate/expr.rs | 2 +- testing/like.test | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/translate/expr.rs b/core/translate/expr.rs index 19e4dc160..3db50331d 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -74,12 +74,12 @@ pub fn translate_condition_expr( } ast::Expr::Binary(lhs, op, rhs) => { let lhs_reg = program.alloc_register(); - let rhs_reg = program.alloc_register(); let _ = translate_expr(program, Some(referenced_tables), lhs, lhs_reg, cursor_hint); match lhs.as_ref() { ast::Expr::Literal(_) => program.mark_last_insn_constant(), _ => {} } + let rhs_reg = program.alloc_register(); let _ = translate_expr(program, Some(referenced_tables), rhs, rhs_reg, cursor_hint); match rhs.as_ref() { ast::Expr::Literal(_) => program.mark_last_insn_constant(), diff --git a/testing/like.test b/testing/like.test index 09fd6af00..3863adf27 100755 --- a/testing/like.test +++ b/testing/like.test @@ -22,6 +22,11 @@ do_execsql_test where-like { } {4|sweater|25.0 5|sweatshirt|74.0} +do_execsql_test where-like-fn { + select * from products where like('sweat%', name)=1 +} {4|sweater|25.0 +5|sweatshirt|74.0} + do_execsql_test where-not-like-and { select * from products where name not like 'sweat%' and price >= 70.0; } {1|hat|79.0