Skip to content

Commit

Permalink
Fix deep-equality as per specification of eqg
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr committed Jan 15, 2025
1 parent 6019b5e commit 91d1c03
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions extension/partiql-extension-ion/src/boxed_ion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ impl<'a, const NULLS_EQUAL: bool, const NAN_EQUAL: bool> NullableEq
{
fn eq(&self, rhs: &Self) -> Value {
let wrap = IonEqualityValue::<'a, { NULLS_EQUAL }, { NAN_EQUAL }, _>;
wrap(&self.0.doc).eq(&wrap(&rhs.0.doc))
NullableEq::eq(&wrap(&self.0.doc), &wrap(&rhs.0.doc))
}
#[inline(always)]
fn eqg(&self, rhs: &Self) -> Value {
let wrap = IonEqualityValue::<'_, true, { NAN_EQUAL }, _>;
NullableEq::eq(&wrap(self.0), &wrap(rhs.0))
}

#[inline(always)]
Expand Down Expand Up @@ -650,7 +655,7 @@ impl<'a, const NULLS_EQUAL: bool, const NAN_EQUAL: bool> NullableEq
let (l, r) = (self.0, other.0);
let l = l.iter().map(wrap);
let r = r.iter().map(wrap);
let res = l.zip(r).all(|(l, r)| l == r);
let res = l.zip(r).all(|(l, r)| l.eqg(&r) == Value::Boolean(true));
Value::Boolean(res)
}

Expand All @@ -669,9 +674,9 @@ impl<'a, const NULLS_EQUAL: bool, const NAN_EQUAL: bool> NullableEq
let (l, r) = (self.0, other.0);
let l = l.iter().map(|(s, elt)| (s, wrap(elt)));
let r = r.iter().map(|(s, elt)| (s, wrap(elt)));
let res = l.zip(r).all(|((ls, lelt), (rs, relt))| {
ls == rs && NullableEq::eq(&lelt, &relt) == Value::Boolean(true)
});
let res = l
.zip(r)
.all(|((ls, lelt), (rs, relt))| ls == rs && lelt.eqg(&relt) == Value::Boolean(true));
Value::Boolean(res)
}

Expand Down

0 comments on commit 91d1c03

Please sign in to comment.