Fixed #2452: comments can now be put within initial SQL files. Thanks, Pawel J. Sawicki.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4040 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3a0733e12c
commit
dabf036604
|
@ -349,6 +349,8 @@ def get_sql_initial_data_for_model(model):
|
||||||
if os.path.exists(sql_file):
|
if os.path.exists(sql_file):
|
||||||
fp = open(sql_file, 'U')
|
fp = open(sql_file, 'U')
|
||||||
for statement in statements.split(fp.read()):
|
for statement in statements.split(fp.read()):
|
||||||
|
# Remove any comments from the file
|
||||||
|
statement = re.sub(r"--.*[\n\Z]", "", statement)
|
||||||
if statement.strip():
|
if statement.strip():
|
||||||
output.append(statement + ";")
|
output.append(statement + ";")
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
Loading…
Reference in New Issue