Ticket #15419: ticket_15419.patch

File ticket_15419.patch, 1.2 KB (added by marcosmoyano, 4 years ago)

First patch proposal

  • django/core/management/sql.py

     
    166166    backend_name = connection.settings_dict['ENGINE'].split('.')[-1]
    167167    sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), backend_name)),
    168168                 os.path.join(app_dir, "%s.sql" % opts.object_name.lower())]
    169     for sql_file in sql_files:
    170         if os.path.exists(sql_file):
    171             fp = open(sql_file, 'U')
     169    sql_realfiles = []
     170    if os.path.isdir(app_dir):
     171        sql_realfiles = [{'lower': os.path.join(app_dir, f.lower()),
     172                          'real': os.path.join(app_dir, f)}
     173                         for f in os.listdir(app_dir) if f.endswith(".sql")]
     174    for sql_file in sql_realfiles:
     175        if sql_file['lower'] in sql_files:
     176            fp = open(sql_file['real'], 'U')
    172177            for statement in statements.split(fp.read().decode(settings.FILE_CHARSET)):
    173178                # Remove any comments from the file
    174179                statement = re.sub(ur"--.*([\n\Z]|$)", "", statement)
Back to Top