Whole file
David-Wobrock/sqlvalidator
The author described this change as “Fix #34 -- Handle parsing a function with a single comma string”. It counts as a record because the check below fails on the code as it stood at c8c95c0de and passes on d7e8b6c46, with nothing else changed between the two runs.
ProjectDavid-Wobrock/sqlvalidator
Fix saved2021-12-22
Sharing licenceMIT · LICENSE
Change size+4 −0
What the code was meant to do, written into the code itself as a save note
Fix #34 -- Handle parsing a function with a single comma string
The change
| 510 | 510 | expression_tokens = [] | |
| 511 | 511 | count_parenthesis = 0 | |
| 512 | 512 | count_square_brackets = 0 | |
| 513 | + | in_string = False | |
| 513 | 514 | while next_token is not None: | |
| 514 | 515 | expression_tokens.append(next_token) | |
| 515 | 516 | if next_token == "(": | |
| ⋯ | |||
| 520 | 521 | count_square_brackets += 1 | |
| 521 | 522 | elif next_token == "]": | |
| 522 | 523 | count_square_brackets -= 1 | |
| 524 | + | elif next_token in String.QUOTES: | |
| 525 | + | in_string = not in_string | |
| 523 | 526 | ||
| 524 | 527 | next_token = next(tokens, None) | |
| 525 | 528 | if next_token is None or ( | |
| 526 | 529 | next_token == "," | |
| 527 | 530 | and count_parenthesis == 0 | |
| 528 | 531 | and count_square_brackets == 0 | |
| 532 | + | and in_string is False | |
| 529 | 533 | ): | |
| 530 | 534 | expression, _ = ExpressionParser.parse( | |
| 531 | 535 | iter(expression_tokens), can_be_type=can_be_type | |
The check that tells the two apart
fail→pass·tests/unit/test_lexer.py::test_function_with_single_comma_string_param
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 itc8c95c0debdc7aedc10702f88c4a9c21319082c8
Broken version dated2021-11-15
Modulesqlvalidator.grammar.lexer
Units changedExpressionListParser
Fingerprinte7a90c50bbbf8905
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-11-15Fix validating between predicate conditions
- 2021-11-15Fix handling Any return type as invalid WHERE/HAVING condition
- 2021-11-14Fix Alias.known_fields for aliased subqueries with specific fields