o
    vh<                     @   s>   d dl Z d dlmZ d dlmZ d dlmZ G dd dZdS )    N)FullResultSet)OrderByList)RemovedInDjango61Warningc                       sH   e Zd Zddd fdd
Z fddZ fddZ fd	d
Z  ZS )OrderableAggMixin )orderingorder_byc                   sj   |rt jdtdd |rtd|}|sd | _nt|ttfr%t| | _nt|| _t	 j
|i | d S )Nz:The ordering argument is deprecated. Use order_by instead.   )category
stacklevelz*Cannot specify both order_by and ordering.)warningswarnr   	TypeErrorr   
isinstancelisttupler   super__init__)selfr   r   expressionsextra	__class__r   g/var/www/html/hyperkenya/venv/lib/python3.10/site-packages/django/contrib/postgres/aggregates/mixins.pyr      s   
zOrderableAggMixin.__init__c                    s   t   | jg S N)r   get_source_expressionsr   )r   r   r   r   r      s   z(OrderableAggMixin.get_source_expressionsc                    s   |^ }| _ t |S r   )r   r   set_source_expressions)r   exprsr   r   r   r   !   s   z(OrderableAggMixin.set_source_expressionsc                    s   |   ^ }}}d}g }|d ur||\}}g }|d ur0z	||\}	}W n	 ty/   Y nw g }
|D ]}|
||d 7 }
q4t j|||d\}}	|g |
||R fS )N    )r   )r   compiler   r   as_sql)r   compiler
connectionsource_exprsfiltering_exprorder_by_exprorder_by_sqlorder_by_paramsfilter_params_source_paramssource_exprsqlr   r   r   r!   %   s"   zOrderableAggMixin.as_sql)__name__
__module____qualname__r   r   r   r!   __classcell__r   r   r   r   r      s
    r   )r   django.core.exceptionsr   django.db.models.expressionsr   django.utils.deprecationr   r   r   r   r   r   <module>   s
    