id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 16457 Deferred FKs make TestCase tests unreliable - no FK constraints checks at all! Piotr Czachur nobody "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? Cheers!" Bug closed Database layer (models, ORM) 1.3 Normal duplicate Unreviewed 0 0 0 0 0 0