sehughes / django-treebeard

Automatically exported from code.google.com/p/django-treebeard
Apache License 2.0
0 stars 0 forks source link

Filtering problem with ManyToMany and User model #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use attached models.py then run the following in django shell

from django.contrib.auth.models import User
from django.contrib.auth.models import AnonymousUser
from intranet.testapp.models import A
from django.db.models import Q

u = User.objects.get(username="mmagin")
u
a = A.add_root(name="the root node")
a
first = a.add_child(name="first")
a.get_children()
second = a.add_child(name="second")
a.get_children()
a.get_children().filter(Q(name="first"))
a.get_children().filter(Q(name="first") | Q(users=u))
u = AnonymousUser()
a.get_children().filter(Q(name="first") | Q(users=u))
u = User.objects.get(username="mmagin")
second.users.add(u)
second.users.all()
a.get_children().filter(Q(name="first") | Q(users=u))
u = AnonymousUser()
a.get_children().filter(Q(name="first") | Q(users=u)) # I would expect this
to return the "first" child node

What is the expected output? What do you see instead?
Returns an empty list, however I would expect to see the child node with
the name "first".

What version of the product are you using? On what operating system?
Django 1.1 beta 1 SVN-10838 running Treebeard 1.1

Please provide any additional information below.
If I create another model it works fine. Seems specific to the User model.

Original issue reported on code.google.com by matt.az...@gmail.com on 27 May 2009 at 2:55

Attachments:

GoogleCodeExporter commented 9 years ago
Matt:

I wrote a test to expose this behavior and found that the problem is not in 
treebeard. The fix seems to be to use 
users=None instead of users=AnonymousUser()

I'm about to commit the test. Since it works in all DB backends, I'm closing 
this bug.

Original comment by gpicon on 14 Jun 2009 at 2:51

GoogleCodeExporter commented 9 years ago
This issue was closed by r96.

Original comment by gpicon on 14 Jun 2009 at 2:52

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 1cf5296ebc.

Original comment by gpicon on 14 Oct 2009 at 3:47