#19580: Unify reverse foreign key and m2m unsaved model querying
-------------------------------------+-------------------------------------
Reporter: Anssi Kääriäinen | Owner: raydeal
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* needs_better_patch: 0 => 1
Comment:
Replying to [comment:47 raydeal]:
> I couldn't find correct rules because M2M worked as always, only changed
behaviour of FK. When object is not saved it raises ValueError, when saved
but related value is None returns <QuerySet []>, which is not consistent
for me. Why?
> Base on doubt from #17541
https://code.djangoproject.com/ticket/17541#comment:8 I asked myself: What
is the difference between not saved object with id (pk) refrerenced from
other object and saved object with field containing None value referenced
by other object, through FK both, from the relation point of view?
> There is no difference - both of them have None value and making related
query in both cases doesn't make sens.
There is a huge difference for me. It's doesn't matter which field is
pointed by m2m field, that's not crucial. The most important thing is that
`Foo()` doesn't exist in the database so any related query makes no sense,
and IMO we should raise an exception only in this particular case. You can
start a discussion on DevelopersMailingList if you don't agree, where
you'll reach a wider audience and see what other think.
Moreover proposed change is not a part of the ticket description, it's
backward incompatible, and was not accepted per se.
--
Ticket URL: <https://code.djangoproject.com/ticket/19580#comment:49>
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/066.b310ca2fbc7a49496ad0082dc2f02449%40djangoproject.com.