Code

Ticket #4680: initial_sql.diff

File initial_sql.diff, 946 bytes (added by Tim Chase, 7 years ago)

"svn diff" against trunk

Line 
1Index: core/management.py
2===================================================================
3--- core/management.py  (revision 5525)
4+++ core/management.py  (working copy)
5@@ -424,12 +424,13 @@
6     # Find custom SQL, if it's available.
7     sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), settings.DATABASE_ENGINE)),
8                  os.path.join(app_dir, "%s.sql" % opts.object_name.lower())]
9+    comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$")
10     for sql_file in sql_files:
11         if os.path.exists(sql_file):
12             fp = open(sql_file, 'U')
13             for statement in statements.split(fp.read()):
14                 # Remove any comments from the file
15-                statement = re.sub(r"--.*[\n\Z]", "", statement)
16+                statement = comment_re.sub(r"\1", statement)
17                 if statement.strip():
18                     output.append(statement + ";")
19             fp.close()