Opened 13 years ago

Closed 13 years ago

#16457 closed Bug (duplicate)

Deferred FKs make TestCase tests unreliable - no FK constraints checks at all!

Reported by: Piotr Czachur Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
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


Hi guys!

  • Database backends which have DatabaseFeatures.can_defer_constraint_checks=True including Postgres psycopg2 create deferred FK during syncdb.
  • Deferred FK means that in case of ROLLBACK no constraing check is performed - illegal FK values are accepted.
  • TestCase is using ROLLBACK to "refresh" database state - you can use illegal FKs in INSERT and UPDATE statemets - no error will be reported, which makes those tests unreliable.

I've noticed that deferred constraints are used by django.db.models.deletion.CASCADE(). Why no to use FK cascades if database supports it, and let user decide which cascades should be set?


Change History (1)

comment:1 by Aymeric Augustin, 13 years ago

Resolution: duplicate
Status: newclosed

This is the same problem as #11665, where there's been a lot of activity last week.

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