Opened 18 years ago

Closed 17 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: no UI/UX: no

Description

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@…> 18 years ago.

Download all attachments as: .zip

Change History (5)

by Bastian Kleineidam <calvin@…>, 18 years ago

comment:1 by mir@…, 17 years ago

Needs tests: set

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

comment:2 by anonymous, 17 years ago

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 manage.py shell
from django.db import transaction
transaction.enter_transaction_management()
transaction.commit()

comment:3 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:4 by Malcolm Tredinnick, 17 years ago

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