Django

Code

Ticket #6724 (closed: duplicate)

Opened 4 months ago

Last modified 4 months ago

loaddata w/ errors displays no warnings or error in output

Reported by: calvins Assigned to: nobody
Milestone: Component: Uncategorized
Version: 0.96 Keywords: loaddata
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

djangobug.tar.gz (4.8 kB) - added by calvins on 03/05/08 13:20:52.
Simple project with correct and incorrect data files

Change History

03/05/08 13:20:52 changed by calvins

  • attachment djangobug.tar.gz added.

Simple project with correct and incorrect data files

03/07/08 06:21:05 changed by russellm

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to duplicate.
  • needs_tests changed.
  • needs_docs changed.

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.


Add/Change #6724 (loaddata w/ errors displays no warnings or error in output)




Change Properties
Action