Ticket #22401: patch.patch

File patch.patch, 1.1 KB (added by Julien GODIN, 11 years ago)

Potential patch

  • .py

    diff --git a/sql-old.py b/sql-new.py
    index b58d89f..a176277 100644
    old new def _split_statements(content):  
    155155    comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$")
    156156    statements = []
    157157    statement = []
     158    infunction = False
    158159    for line in content.split("\n"):
    159160        cleaned_line = comment_re.sub(r"\1", line).strip()
     161         
    160162        if not cleaned_line:
    161163            continue
    162164        statement.append(cleaned_line)
    163         if cleaned_line.endswith(";"):
     165        if cleaned_line.startswith("CREATE"):
     166             infunction=True
     167        if "LANGUAGE" in cleaned_line:
     168             infunction=False   
     169        if cleaned_line.endswith(";") and not infunction:
    164170            statements.append(" ".join(statement))
    165171            statement = []
    166172    return statements
    def emit_post_sync_signal(created_models, verbosity, interactive, db):  
    214220        models.signals.post_syncdb.send(sender=app, app=app,
    215221            created_models=created_models, verbosity=verbosity,
    216222            interactive=interactive, db=db)
     223
Back to Top