Opened 12 years ago

Closed 11 years ago

#3024 closed defect (fixed)

[patch] db backend _commit/_rollback check connection

Reported by: Bastian Kleineidam <calvin@…> Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version:
Severity: normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:


The _commit and _rollback methods in the DB backends should both check if self.connection is not None. This patch does just that.

Attachments (1)

check_connection_for_none.diff (3.5 KB) - added by Bastian Kleineidam <calvin@…> 12 years ago.

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by Bastian Kleineidam <calvin@…>

comment:1 Changed 11 years ago by mir@…

Needs tests: set

Pardon my ignorance, under which circumstances is self.connection == None?

comment:2 Changed 11 years ago by anonymous

The connection is initialized with None. If you immediately call _commit() without calling cursor(), the connection will not be initialized.
Here is a simple code path that would trigger the error:

$ python shell
from django.db import transaction

comment:3 Changed 11 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedReady for checkin

comment:4 Changed 11 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [4691]) Fixed #3024 -- Fixed database commit() and rollback() behaviour so it works
consistently if you execute them before Django has made a database connection.
Thanks Bastian Kleineidam.

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