Whole file
David-Wobrock/sqlvalidator
The author described this change as “Fix #23 -- Handle escaped strings in formatting”. It counts as a record because the check below fails on the code as it stood at fb512610c and passes on 079e317ff, with nothing else changed between the two runs.
ProjectDavid-Wobrock/sqlvalidator
Fix saved2021-07-14
Sharing licenceMIT · LICENSE
Change size+18 −1
What the code was meant to do, written into the code itself as a save note
Fix #23 -- Handle escaped strings in formatting
The change
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | 83 | def split_with_sep(s: str, sep: str): | |
| 84 | - | splitted = s.split(sep) | |
| 84 | + | splitted = split_with_escaping(s, sep) | |
| 85 | 85 | for word in splitted[:-1]: | |
| 86 | 86 | if word: | |
| 87 | 87 | yield word | |
| 88 | 88 | yield sep | |
| 89 | 89 | if splitted[-1]: | |
| 90 | 90 | yield splitted[-1] | |
| 91 | + | ||
| 92 | + | ||
| 93 | + | def split_with_escaping(s: str, sep: str): | |
| 94 | + | splitted = [] | |
| 95 | + | split_iterator = iter(s.split(sep)) | |
| 96 | + | value = next(split_iterator, None) | |
| 97 | + | while value is not None: | |
| 98 | + | # Glue values together if defined | |
| 99 | + | if value.endswith("\\"): | |
| 100 | + | value += sep | |
| 101 | + | next_value = next(split_iterator, None) | |
| 102 | + | if next_value: | |
| 103 | + | value += next_value | |
| 104 | + | # Add to list, and keep looping | |
| 105 | + | splitted.append(value) | |
| 106 | + | value = next(split_iterator, None) | |
| 107 | + | return splitted | |
| 91 | 108 | ||
| 92 | 109 | ||
| 93 | 110 | def merge_stream(s, goals): |
The check that tells the two apart
fail→pass·tests/integration/test_formatting.py::test_escaped_char
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 itfb512610c3aeed66a053e7307022f69aa547885d
Broken version dated2021-06-13
Modulesqlvalidator.grammar.tokeniser
Units changedsplit_with_sep
Fingerprintc01a69f564d7363a
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