Re-add ExpressionWrapper
to CertificationVersionManager
annotations
Not sure why I removed them, but things sure are broken without them
This commit is contained in:
parent
b48c723bc4
commit
1e4fc52531
@ -2,7 +2,7 @@ import re
|
|||||||
|
|
||||||
from semver import VersionInfo
|
from semver import VersionInfo
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import OuterRef, Q, Subquery
|
from django.db.models import OuterRef, Q, ExpressionWrapper, Subquery
|
||||||
from django.core.validators import RegexValidator
|
from django.core.validators import RegexValidator
|
||||||
|
|
||||||
from membershipworks.models import Member, Flag as MembershipWorksFlag
|
from membershipworks.models import Member, Flag as MembershipWorksFlag
|
||||||
@ -110,9 +110,15 @@ class CertificationVersionManager(models.Manager):
|
|||||||
qs = super().get_queryset()
|
qs = super().get_queryset()
|
||||||
latest = qs.filter(definition__pk=OuterRef("definition__pk")).reverse()
|
latest = qs.filter(definition__pk=OuterRef("definition__pk")).reverse()
|
||||||
return qs.annotate(
|
return qs.annotate(
|
||||||
is_latest=Q(pk=Subquery(latest.values("pk")[:1])),
|
is_latest=ExpressionWrapper(
|
||||||
|
Q(pk=Subquery(latest.values("pk")[:1])),
|
||||||
|
output_field=models.BooleanField(),
|
||||||
|
),
|
||||||
# TODO: should do a more correct comparison than just major version
|
# TODO: should do a more correct comparison than just major version
|
||||||
is_current=Q(major=Subquery(latest.values("major")[:1])),
|
is_current=ExpressionWrapper(
|
||||||
|
Q(major=Subquery(latest.values("major")[:1])),
|
||||||
|
output_field=models.BooleanField(),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user