Code

Opened 7 years ago

Closed 7 years ago

#3024 closed defect (fixed)

[patch] db backend _commit/_rollback check connection

Reported by: Bastian Kleineidam <calvin@…> Owned by: adrian
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:

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

Download all attachments as: .zip

Change History (5)

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

comment:1 Changed 7 years ago by mir@…

  • Needs tests set

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

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

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

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:4 Changed 7 years ago by mtredinnick

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

(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.

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.