Filter out comment lines beginning with --.
This commit is contained in:
parent
956b3c6053
commit
36e4a44bfb
1 changed files with 9 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue