Re: [Django] #34195: Duplicate Records created when specifying None as a target in a custom ManyToManyField (was: Duplicate Records created when specifying None as a target in a custom ManyToManyField with sqlite3)

2 views
Skip to first unread message

Django

unread,
Dec 1, 2022, 5:35:27 AM12/1/22
to django-...@googlegroups.com
#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.

Reply all
Reply to author
Forward
0 new messages