Ticket #19416: 19416-1.diff

File 19416-1.diff, 1.7 KB (added by Claude Paroz, 12 years ago)
  • django/core/management/sql.py

    diff --git a/django/core/management/sql.py b/django/core/management/sql.py
    index 78cd17a..ea03e90 100644
    a b def sql_all(app, style, connection):  
    145145def _split_statements(content):
    146146    comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$")
    147147    statements = []
    148     statement = ""
     148    statement = []
    149149    for line in content.split("\n"):
    150150        cleaned_line = comment_re.sub(r"\1", line).strip()
    151151        if not cleaned_line:
    152152            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 = []
    157157    return statements
    158158
    159159
  • tests/regressiontests/initial_sql_regress/sql/simple.sql

    diff --git a/tests/regressiontests/initial_sql_regress/sql/simple.sql b/tests/regressiontests/initial_sql_regress/sql/simple.sql
    index 39363ba..abd9fee 100644
    a b  
    22INSERT INTO initial_sql_regress_simple (name) VALUES ('John'); -- another comment
    33INSERT INTO initial_sql_regress_simple (name) VALUES ('-- Comment Man');
    44INSERT INTO initial_sql_regress_simple (name) VALUES ('Paul');
    5 INSERT INTO initial_sql_regress_simple (name) VALUES ('Ringo');
     5INSERT INTO initial_sql_regress_simple
     6    VALUES (150, 'Ringo');
    67INSERT INTO initial_sql_regress_simple (name) VALUES ('George');
    78INSERT INTO initial_sql_regress_simple (name) VALUES ('Miles O''Brien');
    89INSERT INTO initial_sql_regress_simple (name) VALUES ('Semicolon;Man');
Back to Top