mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
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:
parent
be9d645346
commit
adc57632bc
4 changed files with 26 additions and 3 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue