#34195: Duplicate Records created when specifying None as a target in a custom
ManyToManyField
-------------------------------------+-------------------------------------
     Reporter:  Credentive           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  ManyToManyField,     |             Triage Stage:
  null                               |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

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


Comment:

 > When allowing null values as a target in an M2M field, you are allowed
 to assign "None" as the target of a model. However, if you assign "None"
 multiple times, you will get multiple DB records.
 > Understanding that M2M fields are implemented as join tables, I can see
 why this may be happening, but I think this behavior should be documented
 at least. Note from the example that adding non-null targets multiple
 times produces the expected result (it works, but no extra rows are
 created)

 `NULL` doesn't violate unique constraints or cause conflicts in most
 (all?) databases, that's why it's possible to add multiple
 `NULL`-relations.

 > ... this behavior should be documented at least.

 This is a database behavior, not something that Django is responsible for.
 I'm not sure Django documentation is the right place to document this.
 Closing as "invalid" unless someone strongly believes we should document
 this.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34195#comment:1>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070184cd415c6c-deee3655-9d88-42d0-bc12-f6bb65ad36ad-000000%40eu-central-1.amazonses.com.

Reply via email to