2020-10-23 01:18:04 -04:00
|
|
|
from django.contrib.postgres.aggregates import JSONBAgg
|
2020-04-21 16:13:34 -04:00
|
|
|
from django.db.models import F, Func
|
|
|
|
|
|
|
|
|
|
|
|
class CollateAsChar(Func):
|
|
|
|
"""
|
|
|
|
Disregard localization by collating a field as a plain character string. Helpful for ensuring predictable ordering.
|
|
|
|
"""
|
|
|
|
function = 'C'
|
|
|
|
template = '(%(expressions)s) COLLATE "%(function)s"'
|
2020-10-23 01:18:04 -04:00
|
|
|
|
|
|
|
|
2021-02-24 19:00:14 -05:00
|
|
|
class EmptyGroupByJSONBAgg(JSONBAgg):
|
2020-10-23 01:18:04 -04:00
|
|
|
"""
|
|
|
|
JSONBAgg is a builtin aggregation function which means it includes the use of a GROUP BY clause.
|
|
|
|
When used as an annotation for collecting config context data objects, the GROUP BY is
|
|
|
|
incorrect. This subclass overrides the Django ORM aggregation control to remove the GROUP BY.
|
|
|
|
"""
|
|
|
|
contains_aggregate = False
|