Whole file

David-Wobrock/sqlvalidator

The author described this change as Fix validating between predicate conditions. It counts as a record because the check below fails on the code as it stood at 362ec80af and passes on a3bf4fcc6, with nothing else changed between the two runs.

Fix saved2021-11-15
Sharing licenceMIT · LICENSE
Change size+12 8

What the code was meant to do, written into the code itself as a save note

Fix validating between predicate conditions

The change

14371437 def validate(self, known_fields):
14381438 errors = super().validate(known_fields)
14391439 errors += self.value.validate(known_fields)
1440- errors += self.right_hand.validate(known_fields)
1440+ if self.predicate.lower() == "between":
1441+ errors += self.right_hand.validate(known_fields, is_between_predicate=True)
1442+ else:
1443+ errors += self.right_hand.validate(known_fields)
14411444 return errors
14421445
14431446 @property
14891492 and all(a == o for a, o in zip(self.args, other.args))
14901493 )
14911494
1492- def validate(self, known_fields):
1495+ def validate(self, known_fields, is_between_predicate=False):
14931496 errors = super().validate(known_fields)
14941497 for a in self.args:
14951498 errors += a.validate(known_fields)
1496- a_type = a.resolve_return_type(known_fields)
1497- if a_type not in (bool, Any):
1498- errors.append(
1499- "The argument of {} must be type boolean, not type {}".format(
1500- self.type.upper(), a_type.__name__
1499+ if not is_between_predicate:
1500+ a_type = a.resolve_return_type(known_fields)
1501+ if a_type not in (bool, Any):
1502+ errors.append(
1503+ "The argument of {} must be type boolean, not type {}".format(
1504+ self.type.upper(), a_type.__name__
1505+ )
15011506 )
1502- )
15031507
15041508 return errors
15051509

The check that tells the two apart

failpass·tests/integration/test_validation.py::test_between_condition_is_valid

Check file tests/integration/test_validation.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it362ec80af081a4fe9710832060e8f2f89d545cd2
Broken version dated2021-11-15
Modulesqlvalidator.grammar.sql
Units changedBooleanCondition, Condition
Fingerprint73c5e56ffa60f291
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in David-Wobrock/sqlvalidator