Whole file
David-Wobrock/sqlvalidator
The author described this change as “Fix some unnest parsing”. It counts as a record because the checks below fail on the code as it stood at 7734d5bae and pass on 65c4b2275, with nothing else changed between the two runs.
ProjectDavid-Wobrock/sqlvalidator
Fix saved2021-02-20
Sharing licenceMIT · LICENSE
Change size+10 −7
What the code was meant to do, written into the code itself as a save note
Fix some unnest parsing
The change
| 200 | 200 | next_token = next(tokens, None) | |
| 201 | 201 | else: | |
| 202 | 202 | if lower(next_token) == "unnest": | |
| 203 | - | expression = UnnestParser.parse(tokens) | |
| 204 | - | next_token = next(tokens, None) | |
| 203 | + | expression, next_token = UnnestParser.parse(tokens) | |
| 205 | 204 | else: | |
| 206 | 205 | argument_tokens, next_token = get_tokens_until_one_of( | |
| 207 | 206 | tokens, | |
| ⋯ | |||
| 351 | 350 | offset_alias = next(tokens) | |
| 352 | 351 | else: | |
| 353 | 352 | offset_alias = next_token | |
| 353 | + | next_token = next(tokens, None) | |
| 354 | 354 | ||
| 355 | - | return Unnest( | |
| 356 | - | expression, | |
| 357 | - | with_offset=with_offset, | |
| 358 | - | with_offset_as=with_offset_as, | |
| 359 | - | offset_alias=offset_alias, | |
| 355 | + | return ( | |
| 356 | + | Unnest( | |
| 357 | + | expression, | |
| 358 | + | with_offset=with_offset, | |
| 359 | + | with_offset_as=with_offset_as, | |
| 360 | + | offset_alias=offset_alias, | |
| 361 | + | ), | |
| 362 | + | next_token, | |
| 360 | 363 | ) | |
| 361 | 364 | ||
| 362 | 365 | ||
The check that tells the two apart
fail→pass·tests/integration/test_formatting.py::test_multiple_joins_unnest
fail→pass·tests/integration/test_formatting.py::test_nested_multiple_joins_unnest
Check file tests/integration/test_formatting.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 it7734d5baef3323c7d0a7c1b93fda7a1210d9915c
Broken version dated2021-02-20
Modulesqlvalidator.grammar.lexer
Units changedFromStatementParser, UnnestParser
Fingerprintc08b0094e70b89cb
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