diff --git a/core/translate/expr.rs b/core/translate/expr.rs index 5d081d2a9..c1beb32d2 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -2224,19 +2224,10 @@ fn emit_binary_insn( referenced_tables: Option<&TableReferences>, ) -> Result<()> { let mut affinity = Affinity::Blob; - if matches!( - op, - ast::Operator::Equals - | ast::Operator::NotEquals - | ast::Operator::Less - | ast::Operator::LessEquals - | ast::Operator::Greater - | ast::Operator::GreaterEquals - | ast::Operator::Is - | ast::Operator::IsNot - ) { + if op.is_comparison() { affinity = comparison_affinity(lhs_expr, rhs_expr, referenced_tables); } + match op { ast::Operator::NotEquals => { let if_true_label = program.allocate_label(); diff --git a/vendored/sqlite3-parser/src/parser/ast/mod.rs b/vendored/sqlite3-parser/src/parser/ast/mod.rs index 7512b75d5..6d92c07ba 100644 --- a/vendored/sqlite3-parser/src/parser/ast/mod.rs +++ b/vendored/sqlite3-parser/src/parser/ast/mod.rs @@ -731,6 +731,21 @@ impl Operator { | Operator::NotEquals ) } + + /// Returns true if this operator is a comparison operator that may need affinity conversion + pub fn is_comparison(&self) -> bool { + matches!( + self, + Self::Equals + | Self::NotEquals + | Self::Less + | Self::LessEquals + | Self::Greater + | Self::GreaterEquals + | Self::Is + | Self::IsNot + ) + } } /// Unary operators