Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#16026 closed New feature (fixed)

Inform user which object triggered error in loaddata

Reported by: Gabriel Hurley Owned by: Gabriel Hurley
Component: Core (Management commands) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

When the loaddata command saves objects it is entirely possible for the database to raise an exception, which is all well and good except for the fact that the standard IntegrityError and DatabaseError messages don't mention which object raised the exception. This can make debugging a fixture with dozens, hundreds or thousands of objects in it nearly impossible.

So I've got a patch here which adds one extra line of output notifying the user of which object (and which DB) raised the error before re-raising the exception.

Attachments (2)

loaddata_error.diff (3.5 KB ) - added by Gabriel Hurley 13 years ago.
Full patch with change, test, and additional intentionally invalid fixture.
16026_loaddata_error.diff (3.5 KB ) - added by Gabriel Hurley 13 years ago.
Updated ticket as per Jacob's feedback

Download all attachments as: .zip

Change History (9)

comment:1 by Paul McMillan, 14 years ago

Triage Stage: UnreviewedReady for checkin

This looks good to me. I'm marking it as rfc. This should help reduce the number of support requests we have to deal with.

comment:2 by Luke Plant, 14 years ago

Needs tests: set
Triage Stage: Ready for checkinAccepted

There doesn't seem to be a reason to skip tests - see modeltests/fixtures/tests.py - so I'm changing the flags accordingly.

comment:3 by Gabriel Hurley, 13 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin
UI/UX: unset

Improved the patch to return revised message as the exception string, which is vastly preferable. Unit test now included. Bumping back to RFC having fixed the aforementioned problem.

by Gabriel Hurley, 13 years ago

Attachment: loaddata_error.diff added

Full patch with change, test, and additional intentionally invalid fixture.

comment:4 by Jacob, 13 years ago

Easy pickings: set
Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

This isn't quite RFC: the error message is different on different db engines (e.g. "null value in column "headline" violates not-null constraint" vs "fixtures_article.headline may not be NULL"), so the test fails. Other than that this is perfect; please mark back to RFC when that's fixed.

by Gabriel Hurley, 13 years ago

Attachment: 16026_loaddata_error.diff added

Updated ticket as per Jacob's feedback

comment:5 by Gabriel Hurley, 13 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

Changed to using an assertRegexpMatches for the error string rather than an assertEqual to support differing database error messages. Should be all set now.

comment:6 by Jacob, 13 years ago

#10200 was a duplicate.

comment:7 by Paul McMillan, 13 years ago

Resolution: fixed
Status: newclosed

In [16873]:

Fixed #16026 -- loaddata now identifies which object triggered an error.

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