Fix NONE and NULL less than or greater than bugs (#4658)

This commit is contained in:
Tobie Morgan Hitchcock 2024-09-02 11:03:26 +01:00 committed by GitHub
parent 99356dcd49
commit 329bb74040
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 11 deletions

View file

@ -458,9 +458,17 @@ impl Document {
Value::Subquery(Box::new(Subquery::Ifelse(IfelseStatement {
exprs: vec![(
Value::Expression(Box::new(Expression::Binary {
l: Value::Idiom(key.clone()),
o: Operator::MoreThan,
r: val.clone(),
l: Value::Expression(Box::new(Expression::Binary {
l: Value::Idiom(key.clone()),
o: Operator::Exact,
r: Value::None,
})),
o: Operator::Or,
r: Value::Expression(Box::new(Expression::Binary {
l: Value::Idiom(key.clone()),
o: Operator::MoreThan,
r: val.clone(),
})),
})),
val,
)],
@ -505,9 +513,17 @@ impl Document {
Value::Subquery(Box::new(Subquery::Ifelse(IfelseStatement {
exprs: vec![(
Value::Expression(Box::new(Expression::Binary {
l: Value::Idiom(key.clone()),
o: Operator::LessThan,
r: val.clone(),
l: Value::Expression(Box::new(Expression::Binary {
l: Value::Idiom(key.clone()),
o: Operator::Exact,
r: Value::None,
})),
o: Operator::Or,
r: Value::Expression(Box::new(Expression::Binary {
l: Value::Idiom(key.clone()),
o: Operator::LessThan,
r: val.clone(),
})),
})),
val,
)],

View file

@ -105,19 +105,19 @@ pub fn any_like(a: &Value, b: &Value) -> Result<Value, Error> {
}
pub fn less_than(a: &Value, b: &Value) -> Result<Value, Error> {
Ok((a.is_none_or_null() || b.is_none_or_null() || a.lt(b)).into())
Ok(a.lt(b).into())
}
pub fn less_than_or_equal(a: &Value, b: &Value) -> Result<Value, Error> {
Ok((a.is_none_or_null() || b.is_none_or_null() || a.le(b)).into())
Ok(a.le(b).into())
}
pub fn more_than(a: &Value, b: &Value) -> Result<Value, Error> {
Ok((a.is_none_or_null() || b.is_none_or_null() || a.gt(b)).into())
Ok(a.gt(b).into())
}
pub fn more_than_or_equal(a: &Value, b: &Value) -> Result<Value, Error> {
Ok((a.is_none_or_null() || b.is_none_or_null() || a.ge(b)).into())
Ok(a.ge(b).into())
}
pub fn contain(a: &Value, b: &Value) -> Result<Value, Error> {

View file

@ -54,7 +54,15 @@ async fn define_foreign_table() -> Result<(), Error> {
assert_eq!(tmp, val);
//
let tmp = res.remove(0).result?;
let val = Value::parse("[{ id: person:one, age: 39, score: 70 }]");
let val = Value::parse(
"[
{
age: 39,
id: person:one,
score: 70,
}
]",
);
assert_eq!(tmp, val);
//
let tmp = res.remove(0).result?;