StringAgg(..., distinct=True) crashes

XMLWordPrintableJSON

    • None
    • Python Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Example:

      ERROR: test_distinct_on_stringagg (aggregation.tests.AggregateTestCase.test_distinct_on_stringagg)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/home/tim/code/django/tests/aggregation/tests.py", line 577, in test_distinct_on_stringagg
          books = Book.objects.aggregate(
                  ^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tim/code/django/django/db/models/manager.py", line 87, in manager_method
          return getattr(self.get_queryset(), name)(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tim/code/django/django/db/models/query.py", line 594, in aggregate
          return self.query.chain().get_aggregation(self.db, kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tim/code/django/django/db/models/sql/query.py", line 638, in get_aggregation
          result = compiler.execute_sql(SINGLE)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tim/code/django-mongodb/django_mongodb_backend/compiler.py", line 359, in execute_sql
          self.pre_sql_setup()
        File "/home/tim/code/django-mongodb/django_mongodb_backend/compiler.py", line 310, in pre_sql_setup
          group, group_replacements = self._prepare_annotations_for_aggregation_pipeline(order_by)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tim/code/django-mongodb/django_mongodb_backend/compiler.py", line 168, in _prepare_annotations_for_aggregation_pipeline
          new_replacements, expr_group = self._prepare_expressions_for_pipeline(
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tim/code/django-mongodb/django_mongodb_backend/compiler.py", line 116, in _prepare_expressions_for_pipeline
          replacements[sub_expr] = self._get_replace_expr(sub_expr, group, alias)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/tim/code/django-mongodb/django_mongodb_backend/compiler.py", line 76, in _get_replace_expr
          rhs = sub_expr.as_mql(
                ^^^^^^^^^^^^^^^^
        File "/home/tim/code/django-mongodb/django_mongodb_backend/expressions/builtins.py", line 38, in base_expression
          expr = self.as_mql_expr(compiler, connection, **extra)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      TypeError: string_agg() got an unexpected keyword argument 'resolve_inner_expression'

      NotSupportedError should be raised.

            Assignee:
            Tim Graham
            Reporter:
            Tim Graham
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: