Code

Ticket #2452: management.diff

File management.diff, 628 bytes (added by Pawel J. Sawicki (http://pjs.name), 8 years ago)

Patch that correctly removes any comments presented within any initial sql data files.

Line 
1Index: management.py
2===================================================================
3--- management.py       (revision 3577)
4+++ management.py       (working copy)
5@@ -349,6 +349,10 @@
6         if os.path.exists(sql_file):
7             fp = open(sql_file)
8             for statement in statements.split(fp.read()):
9+                # This regexp ensures that any comments presented within a sql
10+                # statement will be removed.
11+                statement = re.sub(r"--.*[\n\Z]", "", statement)
12+
13                 if statement.strip():
14                     output.append(statement + ";")
15             fp.close()