#30580: django.db.migrations.optimizer error in indention
----------------------------+--------------------------------------
     Reporter:  sijianlin   |                    Owner:  nobody
         Type:  Bug         |                   Status:  closed
    Component:  Migrations  |                  Version:  2.2
     Severity:  Normal      |               Resolution:  needsinfo
     Keywords:              |             Triage Stage:  Unreviewed
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+--------------------------------------

Comment (by sijianlin):

 Please take a look at the the code /django/db/migrations/optimizer.py and
 this is an apparent indention error- the last "else" is not matching with
 the if clause.
 Please assign to the author and get it fixed.
 Thanks

 {{{

    def optimize_inner(self, operations, app_label=None):
         """Inner optimization loop."""
         new_operations = []
         for i, operation in enumerate(operations):
             right = True  # Should we reduce on the right or on the left.
             # Compare it to each operation after it
             for j, other in enumerate(operations[i + 1:]):
                 in_between = operations[i + 1:i + j + 1]
                 result = operation.reduce(other, app_label)
                 if isinstance(result, list):
                     if right:
                         new_operations.extend(in_between)
                         new_operations.extend(result)
                     elif all(op.reduce(other, app_label) is True for op in
 in_between):
                         # Perform a left reduction if all of the in-
 between
                         # operations can optimize through other.
                         new_operations.extend(result)
                         new_operations.extend(in_between)
                     else:
                         # Otherwise keep trying.
                         new_operations.append(operation)
                         break
                     new_operations.extend(operations[i + j + 2:])
                     return new_operations
                 elif not result:
                     # Can't perform a right reduction.
                     right = False
             else:
                 new_operations.append(operation)
         return new_operations
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30580#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.25374a3ab4c60069bd85599fe2a6c4be%40djangoproject.com.

Reply via email to