mirror of https://github.com/django/django.git
Fixed #19416 -- Fixed multi-line commands in initial SQL files
Thanks Aymeric Augustin for detecting this regression.
This commit is contained in:
parent
6d27547d20
commit
5fa5621f57
|
@ -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');
|
||||
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');
|
||||
|
|
Loading…
Reference in New Issue