Variant: Do not use implicit fall-through

The code handling the comparison between the date and string types would
convert the variants to correct types, but only through multi-level
fall-through in the switch statement, which is always a bit of a
dangerous construct.

Added explicit return for the non-trivial case, preventing the need for
the fall-through.

Closes #2502.
This commit is contained in:
Tomas Babej 2021-06-12 15:05:32 -04:00
parent 8f16824538
commit 8b86f16f25

View file

@ -1098,8 +1098,15 @@ bool Variant::operator_partial (const Variant& other) const
{
// Same-day comparison.
case type_string:
if (left.trivial () || right.trivial ())
return false;
{
if (left.trivial () || right.trivial ())
return false;
right.cast (type_date);
Datetime left_date (left._date);
Datetime right_date (right._date);
return left_date.sameDay (right_date);
}
case type_boolean:
case type_integer: