﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20991	[Regression] Admin searches should use distinct, if query involves joins.	iorlas	nobody	"As we can see, in #2818 we have fixed bug in django admin behavior with joins - we should use distinct in this cases. Commit 4938c8e fixed this issue.
But, in a89b156 it was reworked as set of codelines for enhanced conditions. To check for possible joins, was created function lookup_needs_distinct. It looks for field by name(for example, in 'user__docs__name' it takes 'user') and does some checks to verify is it relation object.
As we can see, RelatedObject(any relation) and ManyToManyRel(reverse side of ManyToMany) are handled. But, we also have reverse side of ForeignKey - ManyToOneRel. So yea, we have a problem here - appearance of bug #2818. So I decide to create this pull request. At least, it works perfectly for me.
FYI, I'm not checking for OneToOneRel, because there should be no duplications in this case.

Pull prequest - https://github.com/django/django/pull/1519

Should I write tests for it? I'm not very familiar with testwriting for django and contrib.admin has no tests(except really basic with Selenium), so I don't know when I'll finish it."	Bug	closed	contrib.admin	1.5	Normal	duplicate	admin, regression, distinct		Unreviewed	1	0	0	0	1	0
