Fixed #24748 -- Fixed incorrect GROUP BY on MySQL in some queries

When the query's model had a self-referential foreign key, the
compiler.get_group_by() code incorrectly used the self-referential
foreign key's column (for example parent_id) as GROUP BY clause
when it should have used the model's primary key column (id).
This commit is contained in:
Anssi Kääriäinen 2015-05-05 14:44:33 +03:00 committed by Tim Graham
parent be9d645346
commit adc57632bc
4 changed files with 26 additions and 3 deletions

View file

@ -104,3 +104,8 @@ class Bravo(models.Model):
class Charlie(models.Model):
alfa = models.ForeignKey(Alfa, null=True)
bravo = models.ForeignKey(Bravo, null=True)
class SelfRefFK(models.Model):
name = models.CharField(max_length=50)
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')