Opened 5 years ago

Closed 5 years ago

#11472 closed (invalid)

Users not spanning relationship lookups

Reported by: Streamweaver Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords: relationships
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by ramiro)

I believe there may be a bug related to relationship spanning as relates to User models.

I'm using python 2.6 and Django 1.0.2 and this is consistant across Window and Linux installs.

I have to Models both with relationships to Users, cutting down to relavant parts:

class Project(models.Model):
    owner = models.ForeignKey(User)

class Release(models.Model):
     owner = models.ForeignKey(User)

In my view methods when I use:

u = User.objects.exclude(project__owner__isnull=True, release__owner__isnull=True).distinct()

it returns an error of "no such column: U1.owner_id"

Alternatively when I try:

u = User.objects.filter(project__owner__isnull=False).distinct() | User.objects.filter(project__owner__isnull=False).distinct()

This returns a list of ALL users regardless being an owner of a project or release. Using either of those queries alone also returns all users.

I've checked and checked and this is setup as documented and I believe is a bug. I asked on Django-Users, they believe this is a bug as well.

Attachments (0)

Change History (3)

comment:1 Changed 5 years ago by Streamweaver

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Argh, the formatter removed underscores from the Code I pasted, sorry about that. The example code that does not work is as follows:

u = User.objects.exclude(project__owner__isnull=True, release__owner__isnull=True).distinct()
u = User.objects.filter(project__owner__isnull=False).distinct() | User.objects.filter(project__owner__isnull=False).distinct()

comment:2 Changed 5 years ago by ramiro

  • Description modified (diff)

(reformatted description)

comment:3 Changed 5 years ago by russellm

  • Resolution set to invalid
  • Status changed from new to closed

"They" don't believe this is a bug. "They" didn't answer your question before you posted the ticket. There is a very important difference.

This isn't a bug - it's expected behavior. See the mailing list thread for the reason.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.