Code

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#186 closed enhancement (fixed)

[patch] Refactor django/core/meta.py to eliminate duplicate code

Reported by: rmunn@… Owned by: adrian
Component: Metasystem Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The function_get_list and function_get_iterator functions in django/core/meta.py are identical except for their return type. I propose refactoring them by making function_get_list into a simple wrapper around function_get_iterator.

Attachments (1)

refactor-function-get-list.patch (1.6 KB) - added by rmunn@… 9 years ago.
Proposed patch to refactor function_get_list

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by rmunn@…

Proposed patch to refactor function_get_list

comment:1 Changed 9 years ago by rmunn@…

The only difference between these two functions is that get_iterator calls cursor.fetchmany() at least once, and multiple times if necessary, until all rows have been returned; whereas get_list calls cursor.fetchall() exactly once.

If there is a database where fetchmany() incurs a significant performance penalty versus fetchall(), then it would be worth having two separate functions. But as it is, I see no benefit to the code duplication here.

comment:2 Changed 9 years ago by rmunn@…

  • Summary changed from Refactor django/core/meta.py to eliminate duplicate code to [patch] Refactor django/core/meta.py to eliminate duplicate code

comment:3 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [329]) Fixed #186 -- Refactored meta.py to remove duplicate code between function_get_list and function_get_iterator. Thanks, rmunn@…

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.