query_functions.py 712 B

12345678910111213141516171819
  1. from django.contrib.postgres.aggregates import JSONBAgg
  2. from django.db.models import F, Func
  3. class CollateAsChar(Func):
  4. """
  5. Disregard localization by collating a field as a plain character string. Helpful for ensuring predictable ordering.
  6. """
  7. function = 'C'
  8. template = '(%(expressions)s) COLLATE "%(function)s"'
  9. class EmptyGroupByJSONBAgg(JSONBAgg):
  10. """
  11. JSONBAgg is a builtin aggregation function which means it includes the use of a GROUP BY clause.
  12. When used as an annotation for collecting config context data objects, the GROUP BY is
  13. incorrect. This subclass overrides the Django ORM aggregation control to remove the GROUP BY.
  14. """
  15. contains_aggregate = False