#32662: Refactor a generator out from part of SQLCompiler.get_order_by()
-------------------------------------+-------------------------------------
     Reporter:  Chris Jerdonek       |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Uncategorized        |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Chris Jerdonek:

Old description:

> I noticed that `SQLCompiler.get_order_by()` has a 70-line
> [https://github.com/django/django/blob/aa4acc164d1247c0de515c959f7b09648b57dc42/django/db/models/sql/compiler.py#L297-L368
> chunk of code] whose job is to build up an `order_by` list, which is then
> iterated over
> [https://github.com/django/django/blob/aa4acc164d1247c0de515c959f7b09648b57dc42/django/db/models/sql/compiler.py#L372
> right after]. That chunk of code has 8 `order_by.append()` lines. It
> looks like this could be made cleaner by pulling those lines out into a
> private method that is instead a generator that yields those pairs. That
> would eliminate the need for having `order_by.append()` in several spots,
> and it would reduce the size of the method into two smaller methods.

New description:

 I noticed that `SQLCompiler.get_order_by()` has a 70-line
 
[https://github.com/django/django/blob/aa4acc164d1247c0de515c959f7b09648b57dc42/django/db/models/sql/compiler.py#L297-L368
 chunk of code] whose job is to build up an `order_by` list, which is then
 iterated over
 
[https://github.com/django/django/blob/aa4acc164d1247c0de515c959f7b09648b57dc42/django/db/models/sql/compiler.py#L372
 right after]. That chunk of code has 8 `order_by.append()` lines and an
 
[https://github.com/django/django/blob/aa4acc164d1247c0de515c959f7b09648b57dc42/django/db/models/sql/compiler.py#L357-L358
 order_by.extend()]. It looks like this could be made cleaner by pulling
 those lines out into a private method that is instead a generator that
 yields those pairs. That would eliminate the need for having
 `order_by.append()` in several spots, and it would reduce the size of the
 method into two smaller methods.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32662#comment:1>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.aeda04b16e454096b20dbd4e79fcfc91%40djangoproject.com.

Reply via email to