diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-12-03 20:03:05 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-12-03 20:47:08 +0100 |
| commit | 5fa5621f574f9ae211ed756c3e2ad453470dae8a (patch) | |
| tree | dd0cfc224b9172ecfb82317122512c02838422aa | |
| parent | 6d27547d202586c5f85909de84a012bc177f7a30 (diff) | |
Fixed #19416 -- Fixed multi-line commands in initial SQL files
Thanks Aymeric Augustin for detecting this regression.
| -rw-r--r-- | django/core/management/sql.py | 10 | ||||
| -rw-r--r-- | tests/regressiontests/initial_sql_regress/sql/simple.sql | 3 |
2 files changed, 7 insertions, 6 deletions
diff --git a/django/core/management/sql.py b/django/core/management/sql.py index 78cd17a23a..ea03e9088c 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -145,15 +145,15 @@ def sql_all(app, style, connection): def _split_statements(content): comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$") statements = [] - statement = "" + statement = [] for line in content.split("\n"): cleaned_line = comment_re.sub(r"\1", line).strip() if not cleaned_line: continue - statement += cleaned_line - if statement.endswith(";"): - statements.append(statement) - statement = "" + statement.append(cleaned_line) + if cleaned_line.endswith(";"): + statements.append(" ".join(statement)) + statement = [] return statements diff --git a/tests/regressiontests/initial_sql_regress/sql/simple.sql b/tests/regressiontests/initial_sql_regress/sql/simple.sql index 39363baa9a..abd9fee92b 100644 --- a/tests/regressiontests/initial_sql_regress/sql/simple.sql +++ b/tests/regressiontests/initial_sql_regress/sql/simple.sql @@ -2,7 +2,8 @@ INSERT INTO initial_sql_regress_simple (name) VALUES ('John'); -- another comment INSERT INTO initial_sql_regress_simple (name) VALUES ('-- Comment Man'); INSERT INTO initial_sql_regress_simple (name) VALUES ('Paul'); -INSERT INTO initial_sql_regress_simple (name) VALUES ('Ringo'); +INSERT INTO initial_sql_regress_simple + VALUES (150, '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'); |
