Skip to content

Commit 970622d

Browse files
committed
Bugfix
Handle proper SQL variable type for operators
1 parent 085519a commit 970622d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/alerts/alerts_utils.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,8 @@ fn match_alert_operator(expr: &ConditionConfig) -> Expr {
439439
// if it can be parsed as a number, then parse it
440440
// else keep it as a string
441441
if expr.value.as_ref().is_some_and(|v| !v.is_empty()) {
442-
let value = expr.value.as_ref().unwrap();
443-
let value = NumberOrString::from_string(value.clone());
442+
let string_value = expr.value.as_ref().unwrap();
443+
let value = NumberOrString::from_string(string_value.clone());
444444

445445
// for maintaining column case
446446
let column = format!(r#""{}""#, expr.column);
@@ -451,28 +451,28 @@ fn match_alert_operator(expr: &ConditionConfig) -> Expr {
451451
WhereConfigOperator::GreaterThan => col(column).gt(lit(value)),
452452
WhereConfigOperator::LessThanOrEqual => col(column).lt_eq(lit(value)),
453453
WhereConfigOperator::GreaterThanOrEqual => col(column).gt_eq(lit(value)),
454-
WhereConfigOperator::ILike => col(column).ilike(lit(value)),
455-
WhereConfigOperator::Contains => col(column).like(lit(value)),
454+
WhereConfigOperator::ILike => col(column).ilike(lit(string_value)),
455+
WhereConfigOperator::Contains => col(column).like(lit(string_value)),
456456
WhereConfigOperator::BeginsWith => Expr::BinaryExpr(BinaryExpr::new(
457457
Box::new(col(column)),
458458
Operator::RegexIMatch,
459-
Box::new(lit(format!("^{value}"))),
459+
Box::new(lit(format!("^{string_value}"))),
460460
)),
461461
WhereConfigOperator::EndsWith => Expr::BinaryExpr(BinaryExpr::new(
462462
Box::new(col(column)),
463463
Operator::RegexIMatch,
464-
Box::new(lit(format!("{value}$"))),
464+
Box::new(lit(format!("{string_value}$"))),
465465
)),
466-
WhereConfigOperator::DoesNotContain => col(column).not_ilike(lit(value)),
466+
WhereConfigOperator::DoesNotContain => col(column).not_ilike(lit(string_value)),
467467
WhereConfigOperator::DoesNotBeginWith => Expr::BinaryExpr(BinaryExpr::new(
468468
Box::new(col(column)),
469469
Operator::RegexNotIMatch,
470-
Box::new(lit(format!("^{value}"))),
470+
Box::new(lit(format!("^{string_value}"))),
471471
)),
472472
WhereConfigOperator::DoesNotEndWith => Expr::BinaryExpr(BinaryExpr::new(
473473
Box::new(col(column)),
474474
Operator::RegexNotIMatch,
475-
Box::new(lit(format!("{value}$"))),
475+
Box::new(lit(format!("{string_value}$"))),
476476
)),
477477
_ => unreachable!("value must not be null for operators other than `is null` and `is not null`. Should've been caught in validation")
478478
}

0 commit comments

Comments
 (0)