#33838: Querying issue with ForeignKeys where db_constraint=False
-------------------------------------+-------------------------------------
     Reporter:  Alex Bailey          |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  duplicate
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Closing as duplicate of #33608.

 While Django allows for database constraints to be omitted it doesn't make
 any assumptions with regards to database integrity implications.

 In other words, if you break integrity expectations of `ForeignKey` you
 must also adjust your code to do so and in your particular case if a
 `Book` is still allowed to exist without a person the proper way to
 represent that is by setting `null=True` on your field as you've
 discovered.

 Adapting the ORM to special case `db_constraint=False` like it does with
 `null=True` has a few implications that
 [https://docs.djangoproject.com/en/4.0/internals/contributing/bugs-and-
 features/#requesting-features should be debated on the mailing list]
 before a decision is taken because
 
[https://github.com/django/django/commit/b55cde054ee7dd22f93c3522a8ddb1d04193bcac
 it was not done when the change was merged].

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33838#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070181eec3aa32-ea4ad9f7-749e-4d41-9fbc-a65ff3b0e3d6-000000%40eu-central-1.amazonses.com.

Reply via email to