Django

Code

Ticket #4680: initial_sql.diff

File initial_sql.diff, 0.9 kB (added by Tim Chase, 1 year ago)

"svn diff" against trunk

  • core/management.py

    old new  
    424424    # Find custom SQL, if it's available. 
    425425    sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), settings.DATABASE_ENGINE)), 
    426426                 os.path.join(app_dir, "%s.sql" % opts.object_name.lower())] 
     427    comment_re = re.compile(r"^((?:'[^']*'|[^'])*?)--.*$") 
    427428    for sql_file in sql_files: 
    428429        if os.path.exists(sql_file): 
    429430            fp = open(sql_file, 'U') 
    430431            for statement in statements.split(fp.read()): 
    431432                # Remove any comments from the file 
    432                 statement = re.sub(r"--.*[\n\Z]", "", statement) 
     433                statement = comment_re.sub(r"\1", statement) 
    433434                if statement.strip(): 
    434435                    output.append(statement + ";") 
    435436            fp.close()