Code

Opened 3 years ago

Closed 3 years ago

#16457 closed Bug (duplicate)

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

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

Description

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!

Attachments (0)

Change History (1)

comment:1 Changed 3 years ago by aaugustin

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

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.