Opened 4 years ago

Closed 4 years ago

#32662 closed Cleanup/optimization (fixed)

Refactor a generator out from part of SQLCompiler.get_order_by()

Reported by: Chris Jerdonek Owned by: Chris Jerdonek
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Chris Jerdonek)

I noticed that SQLCompiler.get_order_by() has a 70-line chunk of code whose job is to build up an order_by list, which is then iterated over right after. That chunk of code has 8 order_by.append() lines and an 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.

Change History (6)

comment:1 by Chris Jerdonek, 4 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 4 years ago

Component: UncategorizedDatabase layer (models, ORM)
Triage Stage: UnreviewedAccepted

comment:3 by Chris Jerdonek, 4 years ago

Owner: changed from nobody to Chris Jerdonek
Status: newassigned

comment:5 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 0461b7a6:

Fixed #32662 -- Refactored a generator out of SQLCompiler.get_order_by().

This also renames the asc variable to default_order, markes the
desc variable as unused, fixes a typo in SQLCompiler.get_order_by()
docstring, and reorders some blocks in SQLCompiler._order_by_pairs().

Note: See TracTickets for help on using tickets.
Back to Top