Whole file
David-Wobrock/sqlvalidator
The author described this change as “Fix query after condition 'is null'”. It counts as a record because the check below fails on the code as it stood at 4a1d62acd and passes on e6d2d62dd, with nothing else changed between the two runs.
ProjectDavid-Wobrock/sqlvalidator
Fix saved2021-02-04
Sharing licenceMIT · LICENSE
Change size+8 −6
What the code was meant to do, written into the code itself as a save note
Fix query after condition 'is null'
The change
| 493 | 493 | can_be_type=False, | |
| 494 | 494 | can_alias=True, | |
| 495 | 495 | until_one_of=None, | |
| 496 | + | first_token=None, | |
| 496 | 497 | ) -> Tuple[Expression, Any]: | |
| 497 | 498 | until_one_of = until_one_of or [] | |
| 498 | 499 | ||
| 499 | - | main_token = next(tokens) | |
| 500 | + | main_token = first_token or next(tokens) | |
| 500 | 501 | next_token = None | |
| 501 | 502 | ||
| 502 | 503 | if main_token in String.QUOTES: | |
| ⋯ | |||
| 725 | 726 | symbol = next_token | |
| 726 | 727 | if lower(next_token) == "is": | |
| 727 | 728 | next_next_token = next(tokens) | |
| 729 | + | first_token = None | |
| 728 | 730 | if lower(next_next_token) == "not": | |
| 729 | 731 | symbol = "is not" | |
| 730 | 732 | else: | |
| 731 | - | tokens, _ = get_tokens_until_one_of( | |
| 732 | - | tokens, [], first_token=next_next_token | |
| 733 | - | ) | |
| 734 | - | tokens = iter(tokens) | |
| 733 | + | first_token = next_next_token | |
| 735 | 734 | ||
| 736 | 735 | right_hand, next_token = ExpressionParser.parse( | |
| 737 | - | tokens, is_right_hand=True, until_one_of=until_one_of | |
| 736 | + | tokens, | |
| 737 | + | is_right_hand=True, | |
| 738 | + | until_one_of=until_one_of, | |
| 739 | + | first_token=first_token, | |
| 738 | 740 | ) | |
| 739 | 741 | expression = Condition(expression, symbol, right_hand) | |
| 740 | 742 | elif lower(next_token) == "between": | |
The check that tells the two apart
fail→pass·tests/unit/test_lexer.py::test_where_clause_keeps_generator_intact_is_null_condition
Check file tests/unit/test_lexer.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 it4a1d62acdc4bb866b713fc36ae476d9e6ed91e8b
Broken version dated2021-02-04
Modulesqlvalidator.grammar.lexer
Units changedExpressionParser
Fingerprintf101bd158e1d315f
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
- 2022-04-15Fix #38 -- Handle nested case expressions
- 2021-12-22Fix #29 -- Handle strings containing others quotes
- 2021-12-22Fix #35 -- Handle index based access on function call
- 2021-12-22Fix #34 -- Handle parsing a function with a single comma string
- 2021-11-15Fix validating between predicate conditions
- 2021-11-15Fix handling Any return type as invalid WHERE/HAVING condition