From 3a1d6d8879bcd1188b1a368ebe29c76a79cd4fa3 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Mon, 27 Oct 2025 13:51:59 +0200 Subject: [PATCH] Improve error messages in translate_expr() The current error messages are misleading, as the user may encounter these errors in expressions outside the WHERE clause, too. --- core/translate/expr.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/translate/expr.rs b/core/translate/expr.rs index 441fa5c19..41de6e2f3 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -724,7 +724,9 @@ pub fn translate_expr( ast::Expr::DoublyQualified(_, _, _) => { crate::bail_parse_error!("DoublyQualified should have been rewritten in optimizer") } - ast::Expr::Exists(_) => crate::bail_parse_error!("EXISTS in WHERE clause is not supported"), + ast::Expr::Exists(_) => { + crate::bail_parse_error!("EXISTS is not supported in this position") + } ast::Expr::FunctionCall { name, distinctness: _, @@ -2142,10 +2144,10 @@ pub fn translate_expr( Ok(result_reg) } ast::Expr::InSelect { .. } => { - crate::bail_parse_error!("IN (...subquery) in WHERE clause is not supported") + crate::bail_parse_error!("IN (...subquery) is not supported in this position") } ast::Expr::InTable { .. } => { - crate::bail_parse_error!("Table expression in WHERE clause is not supported") + crate::bail_parse_error!("Table expression is not supported in this position") } ast::Expr::IsNull(expr) => { let reg = program.alloc_register(); @@ -2183,7 +2185,7 @@ pub fn translate_expr( } ast::Expr::Literal(lit) => emit_literal(program, lit, target_register), ast::Expr::Name(_) => { - crate::bail_parse_error!("ast::Expr::Name in WHERE clause is not supported") + crate::bail_parse_error!("ast::Expr::Name is not supported in this position") } ast::Expr::NotNull(expr) => { let reg = program.alloc_register(); @@ -2230,7 +2232,7 @@ pub fn translate_expr( } ast::Expr::Raise(_, _) => crate::bail_parse_error!("RAISE is not supported"), ast::Expr::Subquery(_) => { - crate::bail_parse_error!("Subquery in WHERE clause is not supported") + crate::bail_parse_error!("Subquery is not supported in this position") } ast::Expr::Unary(op, expr) => match (op, expr.as_ref()) { (UnaryOperator::Positive, expr) => {