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.

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

8181
8282
8383 def split_with_sep(s: str, sep: str):
84- splitted = s.split(sep)
84+ splitted = split_with_escaping(s, sep)
8585 for word in splitted[:-1]:
8686 if word:
8787 yield word
8888 yield sep
8989 if splitted[-1]:
9090 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
91108
92109
93110 def merge_stream(s, goals):

The check that tells the two apart

failpass·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