Skip to content

Commit 112890f

Browse files
committed
fix a bug when eval empty string
Committed-by: bingqing.lbq from Dev container
1 parent d1c728a commit 112890f

File tree

1 file changed

+5
-2
lines changed
  • interactive_engine/executor/ir/graph_proxy/src/utils/expr

1 file changed

+5
-2
lines changed

interactive_engine/executor/ir/graph_proxy/src/utils/expr/eval.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::convert::{TryFrom, TryInto};
2020

2121
use dyn_type::arith::{BitOperand, Exp};
2222
use dyn_type::object;
23+
use dyn_type::object::RawType;
2324
use dyn_type::{BorrowObject, Object};
2425
use ir_common::error::{ParsePbError, ParsePbResult};
2526
use ir_common::expr_parse::to_suffix_expr;
@@ -295,7 +296,9 @@ pub(crate) fn apply_logical<'a>(
295296
if b_opt.is_some() {
296297
let b = b_opt.unwrap();
297298
// process null values
298-
if a.eq(&Object::None) || b.eq(&Object::None) {
299+
// "a.eq(&Object::None)" has a potential bug, that if a is empty string "", it will be treated as None.
300+
// Fix it by using raw_type() == RawType::None
301+
if a.raw_type() == RawType::None || b.raw_type() == RawType::None {
299302
match logical {
300303
And => {
301304
if (a != Object::None && !a.eval_bool::<(), NoneContext>(None)?)
@@ -678,7 +681,7 @@ impl TryFrom<common_pb::ExprOpr> for Operand {
678681
Ok(Self::VarMap(vec))
679682
}
680683
Map(key_vals) => Operand::try_from(key_vals),
681-
_ => Err(ParsePbError::ParseError("invalid operators for an Operand".to_string())),
684+
_ => Err(ParsePbError::ParseError(format!("invalid operators for an Operand {:?}", item))),
682685
}
683686
} else {
684687
Err(ParsePbError::from("empty value provided"))

0 commit comments

Comments
 (0)