From 6dacb3d10b4a29cca54e2f0196b24f471a10ceb9 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Mon, 25 Sep 2006 07:36:46 +0000 Subject: [PATCH] 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 --- django/core/management.py | 2 +- tests/regressiontests/initial_sql_regress/sql/simple.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django/core/management.py b/django/core/management.py index b29f437308..87e5053791 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -347,7 +347,7 @@ def get_sql_initial_data_for_model(model): os.path.join(app_dir, "%s.sql" % opts.object_name.lower())] for sql_file in sql_files: if os.path.exists(sql_file): - fp = open(sql_file) + fp = open(sql_file, 'U') for statement in statements.split(fp.read()): if statement.strip(): output.append(statement + ";") diff --git a/tests/regressiontests/initial_sql_regress/sql/simple.sql b/tests/regressiontests/initial_sql_regress/sql/simple.sql index ddb08bc91f..ca9bd40dab 100644 --- a/tests/regressiontests/initial_sql_regress/sql/simple.sql +++ b/tests/regressiontests/initial_sql_regress/sql/simple.sql @@ -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 ('Miles O''Brien'); 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');