#1050: Can't find null objects in a ManyToMany that may be null
-----------------------------------+----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: jacobkm
Type: defect | Status: new
Priority: normal | Milestone:
Component: Database wrapper | Version:
Severity: normal | Resolution:
Keywords: null, manytomany, orm |
-----------------------------------+----------------------------------------
Comment (by [EMAIL PROTECTED]):
I think the 'easiest' way to allow for this case is to allow one to change
the JOIN type .. currently, using INNER JOINS is the issue .. a LEFT JOIN
would allow you to do this
{{{
MyModel.objects.filter(manytomany__id__isnull = True)
}}}
however, there is no method to 'detect' the isnull on the primary key ...
i.e. change this
{{{
SELECT ... FROM app_mymodel INNER JOIN app_manytomany AS
app_app_manytomany ON app_mymodel.id = app_app_manytomany.asset_id WHERE
(app_app_manytomany.id IS NULL)
}}}
to
{{{
SELECT ... FROM app_mymodel LEFT JOIN app_manytomany AS
app_app_manytomany ON app_mymodel.id = app_app_manytomany.mymodel_id WHERE
(app_app_manytomany.id IS NULL)
}}}
the former will always return nothing (unless of course the id can be
null, but since when should a primary key autoinc field be null? :)
so maybe it can detect something like
{{{
MyModel.objects.filter(manytomany__pk__isnull = True)
}}}
(the pk flag to force this this to be true) ..
the issue with not supporting this, means the usual filter chaining cannot
be done as it currently needs be a special static query
--
Ticket URL: <http://code.djangoproject.com/ticket/1050#comment:>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---