Whole file
akaihola/pgtricks
The author described this change as “Warn instead of crash on unidentified SQL”. It counts as a record because the check below fails on the code as it stood at e7b9a5f6c and passes on 7b69b1160, with nothing else changed between the two runs.
Projectakaihola/pgtricks
Fix saved2020-06-24
Sharing licenceBSD-3-Clause · LICENSE
Change size+8 −1
What the code was meant to do, written into the code itself as a save note
Warn instead of crash on unidentified SQL
The change
| 17 | 17 | import os | |
| 18 | 18 | import re | |
| 19 | 19 | import sys | |
| 20 | + | import warnings | |
| 20 | 21 | ||
| 21 | 22 | SPLIT_RE = re.compile( | |
| 22 | 23 | r''' | |
| ⋯ | |||
| 53 | 54 | part = sql[start:end] | |
| 54 | 55 | match = IDENTIFY_RE.match(part) | |
| 55 | 56 | if not match: | |
| 57 | + | warnings.warn( | |
| 58 | + | "Can't identify the following SQL chunk in {sqlpath}:\n" | |
| 59 | + | "{divider}\n" | |
| 60 | + | "{chunk}\n" | |
| 61 | + | "{divider}".format(sqlpath=sqlpath, chunk=part, divider=77 * '=') | |
| 62 | + | ) | |
| 56 | 63 | print(part) | |
| 57 | - | sys.exit(0) | |
| 64 | + | continue | |
| 58 | 65 | name = match.group(1).replace(" ", "_") | |
| 59 | 66 | type_ = match.group(2).replace(" ", "_") | |
| 60 | 67 | schema = match.group(3) | |
The check that tells the two apart
fail→pass·pgtricks/tests/test_pg_split_schema_dump.py::test_split_sql_file_unrecognized_content
Check file pgtricks/tests/test_pg_split_schema_dump.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 ite7b9a5f6cdcc3fa874b215c77f3e87d4aee19d46
Broken version dated2020-06-23
Modulepgtricks.pg_split_schema_dump
Units changedsplit_sql_file
Fingerprint83ec2ebf482c4740
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.