Filter out comment lines beginning with --.

This commit is contained in:
voussoir 2022-03-23 23:08:43 -07:00
parent 956b3c6053
commit 36e4a44bfb
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -238,6 +238,14 @@ def _extract_columns_from_table(create_table_statement):
column_names = [c for c in column_names if c.lower() not in constraints]
return column_names
def _remove_script_comments(script):
lines = []
for line in script.splitlines():
if re.match(r'^\s*--', line):
continue
lines.append(line)
return '\n'.join(lines)
def _reverse_index(columns):
return {column: index for (index, column) in enumerate(columns)}
@ -257,6 +265,7 @@ def extract_table_column_map(script):
}
'''
columns = {}
script = _remove_script_comments(script)
create_table_statements = _extract_create_table_statements(script)
for create_table_statement in create_table_statements:
table_name = _extract_table_name(create_table_statement)