Opened 12 years ago

Closed 12 years ago

#18738 closed Uncategorized (duplicate)

manage.py loaddata returns 0 despite fixture load failure

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

Description

I tried to load some fixtures with the PostgreSQL backend and got an integrity error because the fixtures were in the wrong order:

$ python manage.py loaddata fixtures.yaml
Problem installing fixture 'fixtures.yaml.bz2': Traceback (most recent call last):
  File "/Users/lorin/.virtualenvs/venv/src/django/django/core/management/commands/loaddata.py", line 226, in handle
    connection.check_constraints(table_names=table_names)
  File "/Users/lorin/.virtualenvs/venv/src/django/django/db/backends/postgresql_psycopg2/base.py", line 129, in check_constraints
    self.cursor().execute('SET CONSTRAINTS ALL IMMEDIATE')
  File "/Users/lorin/.virtualenvs/venv/src/django/django/db/backends/util.py", line 40, in execute
    return self.cursor.execute(sql, params)
  File "/Users/lorin/.virtualenvs/venv/src/django/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
    return self.cursor.execute(query, args)
IntegrityError: insert or update on table "shop_product" violates foreign key constraint "shop_product_product_ptr_id_fkey"
DETAIL:  Key (product_ptr_id)=(1) is not present in table "shop_product".

I expected the return code to indicate failure. However, it returned success:

$ echo $?
0	

This is problematic in environments when relying on the return code to indicate success or failure.

Change History (1)

comment:1 by Ramiro Morales, 12 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #10200. The fix for such ticket was implemented after the release of 1.4, so:

  • Will be available in 1.5.
  • Won't be present in 1.4 nor any 1.4.x release.
Note: See TracTickets for help on using tickets.
Back to Top