Opened 3 years ago

Closed 3 years ago

#18738 closed Uncategorized (duplicate) loaddata returns 0 despite fixture load failure

Reported by: lorinh 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


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

$ python 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/", line 226, in handle
  File "/Users/lorin/.virtualenvs/venv/src/django/django/db/backends/postgresql_psycopg2/", line 129, in check_constraints
    self.cursor().execute('SET CONSTRAINTS ALL IMMEDIATE')
  File "/Users/lorin/.virtualenvs/venv/src/django/django/db/backends/", line 40, in execute
    return self.cursor.execute(sql, params)
  File "/Users/lorin/.virtualenvs/venv/src/django/django/db/backends/postgresql_psycopg2/", 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 $?

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

Change History (1)

comment:1 Changed 3 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

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