Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#6724 closed (duplicate)

loaddata w/ errors displays no warnings or error in output

Reported by: calvins Owned by: nobody
Component: Uncategorized Version: 0.96
Severity: Keywords: loaddata
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In brief, the problem is that django does not show any indication of an error having occurred when using loaddata under certain conditions, even though a transaction rollback occurred and nothing was added to the database.

The following illustrates the problem:

calvins@gould ~/djangobug $ ./manage.py sqlreset bug| psql djangobug && ./manage.py --verbosity=2 loaddata incorrect_data.xml
BEGIN
ALTER TABLE
DROP TABLE
DROP TABLE
NOTICE:  CREATE TABLE will create implicit sequence "bug_zxcv_id_seq" for serial column "bug_zxcv.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "bug_zxcv_pkey" for table "bug_zxcv"
CREATE TABLE
NOTICE:  CREATE TABLE will create implicit sequence "bug_asdf_id_seq" for serial column "bug_asdf.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "bug_asdf_pkey" for table "bug_asdf"
CREATE TABLE
ALTER TABLE
CREATE INDEX
COMMIT
Loading 'incorrect_data.xml' fixtures...
Checking '/usr/lib/python2.4/site-packages/django/contrib/auth/fixtures' for fixtures...
Trying '/usr/lib/python2.4/site-packages/django/contrib/auth/fixtures' for xml fixture 'incorrect_data'...
No xml fixture 'incorrect_data' in '/usr/lib/python2.4/site-packages/django/contrib/auth/fixtures'.
Checking '/usr/lib/python2.4/site-packages/django/contrib/contenttypes/fixtures' for fixtures...
Trying '/usr/lib/python2.4/site-packages/django/contrib/contenttypes/fixtures' for xml fixture 'incorrect_data'...
No xml fixture 'incorrect_data' in '/usr/lib/python2.4/site-packages/django/contrib/contenttypes/fixtures'.
Checking '/usr/lib/python2.4/site-packages/django/contrib/sessions/fixtures' for fixtures...
Trying '/usr/lib/python2.4/site-packages/django/contrib/sessions/fixtures' for xml fixture 'incorrect_data'...
No xml fixture 'incorrect_data' in '/usr/lib/python2.4/site-packages/django/contrib/sessions/fixtures'.
Checking '/usr/lib/python2.4/site-packages/django/contrib/sites/fixtures' for fixtures...
Trying '/usr/lib/python2.4/site-packages/django/contrib/sites/fixtures' for xml fixture 'incorrect_data'...
No xml fixture 'incorrect_data' in '/usr/lib/python2.4/site-packages/django/contrib/sites/fixtures'.
Checking '/home/calvins/djangobug/../djangobug/bug/fixtures' for fixtures...
Trying '/home/calvins/djangobug/../djangobug/bug/fixtures' for xml fixture 'incorrect_data'...
No xml fixture 'incorrect_data' in '/home/calvins/djangobug/../djangobug/bug/fixtures'.
Checking absolute path for fixtures...
Trying absolute path for xml fixture 'incorrect_data'...
Installing xml fixture 'incorrect_data' from absolute path.
Installed 39 object(s) from 1 fixture(s)

The output says that 39 objects were installed from 1 fixture, and gives no indication of there being errors or problems. But the data file contains two objects that were not added to the database. One of them has a data integrity problem (which initially occurred because I had made a schema change and forgot to syncdb), which prevents that object from being added, but the correct object was also not added, presumably because everything was in a transaction that was rolled back.

The following is the output using the correct data:

calvins@gould ~/djangobug $ ./manage.py sqlreset bug| psql djangobug && ./manage.py --verbosity=2 loaddata correct_data.xml
BEGIN
ALTER TABLE
DROP TABLE
DROP TABLE
NOTICE:  CREATE TABLE will create implicit sequence "bug_zxcv_id_seq" for serial column "bug_zxcv.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "bug_zxcv_pkey" for table "bug_zxcv"
CREATE TABLE
NOTICE:  CREATE TABLE will create implicit sequence "bug_asdf_id_seq" for serial column "bug_asdf.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "bug_asdf_pkey" for table "bug_asdf"
CREATE TABLE
ALTER TABLE
CREATE INDEX
COMMIT
Loading 'correct_data.xml' fixtures...
Checking '/usr/lib/python2.4/site-packages/django/contrib/auth/fixtures' for fixtures...
Trying '/usr/lib/python2.4/site-packages/django/contrib/auth/fixtures' for xml fixture 'correct_data'...
No xml fixture 'correct_data' in '/usr/lib/python2.4/site-packages/django/contrib/auth/fixtures'.
Checking '/usr/lib/python2.4/site-packages/django/contrib/contenttypes/fixtures' for fixtures...
Trying '/usr/lib/python2.4/site-packages/django/contrib/contenttypes/fixtures' for xml fixture 'correct_data'...
No xml fixture 'correct_data' in '/usr/lib/python2.4/site-packages/django/contrib/contenttypes/fixtures'.
Checking '/usr/lib/python2.4/site-packages/django/contrib/sessions/fixtures' for fixtures...
Trying '/usr/lib/python2.4/site-packages/django/contrib/sessions/fixtures' for xml fixture 'correct_data'...
No xml fixture 'correct_data' in '/usr/lib/python2.4/site-packages/django/contrib/sessions/fixtures'.
Checking '/usr/lib/python2.4/site-packages/django/contrib/sites/fixtures' for fixtures...
Trying '/usr/lib/python2.4/site-packages/django/contrib/sites/fixtures' for xml fixture 'correct_data'...
No xml fixture 'correct_data' in '/usr/lib/python2.4/site-packages/django/contrib/sites/fixtures'.
Checking '/home/calvins/djangobug/../djangobug/bug/fixtures' for fixtures...
Trying '/home/calvins/djangobug/../djangobug/bug/fixtures' for xml fixture 'correct_data'...
No xml fixture 'correct_data' in '/home/calvins/djangobug/../djangobug/bug/fixtures'.
Checking absolute path for fixtures...
Trying absolute path for xml fixture 'correct_data'...
Installing xml fixture 'correct_data' from absolute path.
Installed 39 object(s) from 1 fixture(s)

The output looks the same, but the objects were added this time.

I'm attaching a tarball containing a simple project with two kinds of model objects. In the root directory of the project, there are two data files, incorrect_data.xml and correct_data.xml. Running loaddata on either one shows the same output, with no indication of failure, though loading incorrect_data.xml results in nothing being added to the database and correct_data results in the data correctly being added.

Attachments (1)

djangobug.tar.gz (4.8 KB ) - added by calvins 16 years ago.
Simple project with correct and incorrect data files

Download all attachments as: .zip

Change History (3)

by calvins, 16 years ago

Attachment: djangobug.tar.gz added

Simple project with correct and incorrect data files

comment:1 by Russell Keith-Magee, 16 years ago

Resolution: duplicate
Status: newclosed

Thanks for the test case - this is very helpful. I'm fairly certain that this is a duplicate of #4499; I've put some follow up comments on that ticket.

in reply to:  1 comment:2 by Phil Mocek, 15 years ago

Replying to russellm:

I'm fairly certain that this is a duplicate of #4499;
I've put some follow up comments on that ticket.

Note that #4499 is specific to use of PostgreSQL. While the
example provided with this ticked involves PostgreSQL, its
summary and description indicate no such specificity.

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