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.

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

1717 import os
1818 import re
1919 import sys
20+import warnings
2021
2122 SPLIT_RE = re.compile(
2223 r'''
5354 part = sql[start:end]
5455 match = IDENTIFY_RE.match(part)
5556 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+ )
5663 print(part)
57- sys.exit(0)
64+ continue
5865 name = match.group(1).replace(" ", "_")
5966 type_ = match.group(2).replace(" ", "_")
6067 schema = match.group(3)

The check that tells the two apart

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