Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

Thanks Aymeric Augustin for detecting this regression.
  • Loading branch information...
commit 5fa5621f574f9ae211ed756c3e2ad453470dae8a 1 parent 6d27547
Claude Paroz authored December 03, 2012
10  django/core/management/sql.py
@@ -145,15 +145,15 @@ def sql_all(app, style, connection):
145 145
 def _split_statements(content):
146 146
     comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$")
147 147
     statements = []
148  
-    statement = ""
  148
+    statement = []
149 149
     for line in content.split("\n"):
150 150
         cleaned_line = comment_re.sub(r"\1", line).strip()
151 151
         if not cleaned_line:
152 152
             continue
153  
-        statement += cleaned_line
154  
-        if statement.endswith(";"):
155  
-            statements.append(statement)
156  
-            statement = ""
  153
+        statement.append(cleaned_line)
  154
+        if cleaned_line.endswith(";"):
  155
+            statements.append(" ".join(statement))
  156
+            statement = []
157 157
     return statements
158 158
 
159 159
 
3  tests/regressiontests/initial_sql_regress/sql/simple.sql
@@ -2,7 +2,8 @@
2 2
 INSERT INTO initial_sql_regress_simple (name) VALUES ('John'); -- another comment
3 3
 INSERT INTO initial_sql_regress_simple (name) VALUES ('-- Comment Man');
4 4
 INSERT INTO initial_sql_regress_simple (name) VALUES ('Paul');
5  
-INSERT INTO initial_sql_regress_simple (name) VALUES ('Ringo');
  5
+INSERT INTO initial_sql_regress_simple
  6
+    VALUES (150, 'Ringo');
6 7
 INSERT INTO initial_sql_regress_simple (name) VALUES ('George');
7 8
 INSERT INTO initial_sql_regress_simple (name) VALUES ('Miles O''Brien');
8 9
 INSERT INTO initial_sql_regress_simple (name) VALUES ('Semicolon;Man');

0 notes on commit 5fa5621

Michael Manfre

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

Please sign in to comment.
Something went wrong with that request. Please try again.