Fixed #2729 -- Handle initial SQL with different line-ending styles (Windows

vs. Unix vs. Mac). Thanks, Simon Greenhill.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3821 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2006-09-25 07:36:46 +00:00
parent f1c63992f7
commit 6dacb3d10b
2 changed files with 2 additions and 1 deletions

View File

@ -347,7 +347,7 @@ def get_sql_initial_data_for_model(model):
os.path.join(app_dir, "%s.sql" % opts.object_name.lower())] os.path.join(app_dir, "%s.sql" % opts.object_name.lower())]
for sql_file in sql_files: for sql_file in sql_files:
if os.path.exists(sql_file): if os.path.exists(sql_file):
fp = open(sql_file) fp = open(sql_file, 'U')
for statement in statements.split(fp.read()): for statement in statements.split(fp.read()):
if statement.strip(): if statement.strip():
output.append(statement + ";") output.append(statement + ";")

View File

@ -4,4 +4,5 @@ INSERT INTO initial_sql_regress_simple (name) VALUES ('Ringo');
INSERT INTO initial_sql_regress_simple (name) VALUES ('George'); INSERT INTO initial_sql_regress_simple (name) VALUES ('George');
INSERT INTO initial_sql_regress_simple (name) VALUES ('Miles O''Brien'); INSERT INTO initial_sql_regress_simple (name) VALUES ('Miles O''Brien');
INSERT INTO initial_sql_regress_simple (name) VALUES ('Semicolon;Man'); INSERT INTO initial_sql_regress_simple (name) VALUES ('Semicolon;Man');
INSERT INTO initial_sql_regress_simple (name) VALUES ('This line has a Windows line ending');