[Django] #20956: Do not check conn['ENGINE'] existence twice in django.db.utils.ConnectionHandler

2 views
Skip to first unread message

Django

unread,
Aug 22, 2013, 5:29:25 AM8/22/13
to django-...@googlegroups.com
#20956: Do not check conn['ENGINE'] existence twice in
django.db.utils.ConnectionHandler
----------------------------------------------+--------------------
Reporter: koorgoo | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Database layer (models, ORM) | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
----------------------------------------------+--------------------
During code surfing I found a piece of code to optimize.

In
[[https://github.com/django/django/blob/master/django/db/utils.py#L175|this
line]] the `conn['ENGINE']` is set to `'django.db.backends.dummy'` if it
is missed.
In
[[https://github.com/django/django/blob/master/django/db/utils.py#L176|the
next line]] it is checked for existence.

We can remove this check.

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

Django

unread,
Aug 22, 2013, 5:35:45 AM8/22/13
to django-...@googlegroups.com
#20956: Do not check conn['ENGINE'] existence twice in
django.db.utils.ConnectionHandler
-------------------------------------+-------------------------------------
Reporter: koorgoo | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.5
Component: Database layer | Resolution:
(models, ORM) | Triage Stage:
Severity: Normal | Unreviewed
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by koorgoo):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Created [[https://github.com/django/django/pull/1504|a push request]] for
this ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/20956#comment:1>

Django

unread,
Aug 22, 2013, 7:47:43 AM8/22/13
to django-...@googlegroups.com
#20956: Do not check conn['ENGINE'] existence twice in
django.db.utils.ConnectionHandler
-------------------------------------+-------------------------------------
Reporter: koorgoo | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: 1.5
Component: Database layer | Resolution:
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by mjtamlyn):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/20956#comment:2>

Django

unread,
Aug 22, 2013, 8:57:16 AM8/22/13
to django-...@googlegroups.com
#20956: Do not check conn['ENGINE'] existence twice in
django.db.utils.ConnectionHandler
-------------------------------------+-------------------------------------
Reporter: koorgoo | Owner: nobody
Type: | Status: closed
Cleanup/optimization | Version: 1.5
Component: Database layer | Resolution: fixed

(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"ce0e86cf761dc182ae6fb8c0d68964955d19ec75"]:
{{{
#!CommitTicketReference repository=""
revision="ce0e86cf761dc182ae6fb8c0d68964955d19ec75"
Fixed #20956 -- Removed useless check in django.db.utils
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20956#comment:3>

Django

unread,
Aug 22, 2013, 9:48:26 AM8/22/13
to django-...@googlegroups.com
#20956: Do not check conn['ENGINE'] existence twice in
django.db.utils.ConnectionHandler
-------------------------------------+-------------------------------------
Reporter: koorgoo | Owner: nobody

Type: | Status: closed
Cleanup/optimization | Version: 1.5
Component: Database layer | Resolution: fixed
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"768bbf3efe0c412bced1e865e90139a0f07dc613"]:
{{{
#!CommitTicketReference repository=""
revision="768bbf3efe0c412bced1e865e90139a0f07dc613"
Revert "Fixed #20956 -- Removed useless check in django.db.utils"

This reverts commit ce0e86cf761dc182ae6fb8c0d68964955d19ec75.

The check is necessary if 'ENGINE' is an empty string.
Thanks apollo13 for pointing this out.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20956#comment:4>

Django

unread,
Aug 22, 2013, 9:48:47 AM8/22/13
to django-...@googlegroups.com
#20956: Do not check conn['ENGINE'] existence twice in
django.db.utils.ConnectionHandler
-------------------------------------+-------------------------------------
Reporter: koorgoo | Owner: nobody

Type: | Status: closed
Cleanup/optimization | Version: 1.5
Component: Database layer | Resolution: invalid

(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 1 |
-------------------------------------+-------------------------------------
Changes (by timo):

* resolution: fixed => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/20956#comment:5>

Django

unread,
Aug 22, 2013, 10:12:47 AM8/22/13
to django-...@googlegroups.com
#20956: Do not check conn['ENGINE'] existence twice in
django.db.utils.ConnectionHandler
-------------------------------------+-------------------------------------
Reporter: koorgoo | Owner: nobody

Type: | Status: closed
Cleanup/optimization | Version: 1.5
Component: Database layer | Resolution: invalid
(models, ORM) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 1 |
-------------------------------------+-------------------------------------

Comment (by koorgoo):

Sorry, guys.
Will be more accurate next time.

--
Ticket URL: <https://code.djangoproject.com/ticket/20956#comment:6>

Reply all
Reply to author
Forward
0 new messages