mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #34176 -- Fixed grouping by ambiguous aliases.
Regression inb7b28c7c18. Refs #31377. Thanks Shai Berger for the report and reviews. test_aggregation_subquery_annotation_values_collision() has been updated as queries that are explicitly grouped by a subquery should always be grouped by it and not its outer columns even if its alias collides with referenced table columns. This was not possible to accomplish at the time10866a10landed because we didn't have compiler level handling of colliding aliases.
This commit is contained in:
committed by
Mariusz Felisiak
parent
016bead6a2
commit
dd68af62b2
@@ -89,3 +89,49 @@ class SelfRefFK(models.Model):
|
||||
parent = models.ForeignKey(
|
||||
"self", models.SET_NULL, null=True, blank=True, related_name="children"
|
||||
)
|
||||
|
||||
|
||||
class AuthorProxy(Author):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
class Recipe(models.Model):
|
||||
name = models.CharField(max_length=20)
|
||||
author = models.ForeignKey(AuthorProxy, models.CASCADE)
|
||||
tasters = models.ManyToManyField(AuthorProxy, related_name="recipes")
|
||||
|
||||
|
||||
class RecipeProxy(Recipe):
|
||||
class Meta:
|
||||
proxy = True
|
||||
|
||||
|
||||
class AuthorUnmanaged(models.Model):
|
||||
age = models.IntegerField()
|
||||
|
||||
class Meta:
|
||||
db_table = Author._meta.db_table
|
||||
managed = False
|
||||
|
||||
|
||||
class RecipeTasterUnmanaged(models.Model):
|
||||
recipe = models.ForeignKey("RecipeUnmanaged", models.CASCADE)
|
||||
author = models.ForeignKey(
|
||||
AuthorUnmanaged, models.CASCADE, db_column="authorproxy_id"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = Recipe.tasters.through._meta.db_table
|
||||
|
||||
|
||||
class RecipeUnmanaged(models.Model):
|
||||
author = models.ForeignKey(AuthorUnmanaged, models.CASCADE)
|
||||
tasters = models.ManyToManyField(
|
||||
AuthorUnmanaged, through=RecipeTasterUnmanaged, related_name="+"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
db_table = Recipe._meta.db_table
|
||||
|
||||
Reference in New Issue
Block a user