1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 12:55:09 +00:00

LibSQL: Short-circuit single-element tuple comparisons

If a tuple has a single value, perform a comparison using that singular
value. This allows, for example, comparisons of the form "(1) < 4",
where (1) is a single element tuple.
This commit is contained in:
Timothy Flynn 2022-02-11 09:46:06 -05:00 committed by Linus Groh
parent e13c96157c
commit b15db851fe

View file

@ -983,8 +983,11 @@ bool TupleImpl::can_cast(Value const& other_value) const
int TupleImpl::compare(Value const& other) const
{
if (other.type() != SQLType::Tuple)
if (other.type() != SQLType::Tuple) {
if (size() == 1)
return Value(value().at(0)).compare(other);
return 1;
}
auto& other_impl = other.get_impl<TupleImpl>({});
if (m_descriptor && other_impl.m_descriptor && m_descriptor->compare_ignoring_names(*other_impl.m_descriptor))