Permalink
Browse files

Fixed #19416 -- Fixed multi-line commands in initial SQL files

Thanks Aymeric Augustin for detecting this regression.
  • Loading branch information...
1 parent 6d27547 commit 5fa5621f574f9ae211ed756c3e2ad453470dae8a @claudep claudep committed Dec 3, 2012
Showing with 7 additions and 6 deletions.
  1. +5 −5 django/core/management/sql.py
  2. +2 −1 tests/regressiontests/initial_sql_regress/sql/simple.sql
@@ -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
@@ -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');
manfre
manfre Dec 10, 2012 Contributor

Why was this test converted to an identity insert? This bypasses SQLCompilers and any backend that needs to do special handling for identity inserts.

claudep
claudep Dec 10, 2012 Member

Thanks, fixed in 0cdfa76

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');

0 comments on commit 5fa5621

Please sign in to comment.