a
    ÛEbÈ  ã                   @   sà   d dl Z d dlmZ d dlmZmZmZmZ d dlm	Z	 ddl
mZ g d¢Zeƒ ZG dd	„ d	ƒZG d
d„ deeeƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deeeƒZG dd„ deeeƒZdS )é    N)Ú
ArrayField)Ú	AggregateÚBooleanFieldÚ	JSONFieldÚValue)ÚRemovedInDjango50Warningé   )ÚOrderableAggMixin)ÚArrayAggÚBitAndÚBitOrÚBoolAndÚBoolOrÚJSONBAggÚ	StringAggc                       s*   e Zd Zedœ‡ fdd„
Zdd„ Z‡  ZS )ÚDeprecatedConvertValueMixin)Údefaultc                   s4   |t u rd }d| _nd| _tƒ j|d|i|¤Ž d S )NFTr   )ÚNOT_PROVIDEDÚ_default_providedÚsuperÚ__init__)Úselfr   ZexpressionsÚextra©Ú	__class__© új/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/django/contrib/postgres/aggregates/general.pyr      s
    z$DeprecatedConvertValueMixin.__init__c                 C   s(   |d u r$| j s$tj| jtd� | jS |S )N)Úcategory)r   ÚwarningsÚwarnÚdeprecation_msgr   Údeprecation_value)r   ÚvalueÚ
expressionÚ
connectionr   r   r   Úconvert_value!   s    z)DeprecatedConvertValueMixin.convert_value)Ú__name__Ú
__module__Ú__qualname__r   r   r%   Ú__classcell__r   r   r   r   r      s   r   c                   @   s4   e Zd ZdZdZdZedd„ ƒZdZedd„ ƒZ	d	S )
r
   Z	ARRAY_AGGú6%(function)s(%(distinct)s%(expressions)s %(ordering)s)Tc                 C   s   g S ©Nr   ©r   r   r   r   Ú<lambda>.   ó    zArrayAgg.<lambda>zÕIn Django 5.0, ArrayAgg() will return None instead of an empty list if there are no rows. Pass default=None to opt into the new behavior and silence this warning or default=Value([]) to keep the previous behavior.c                 C   s   t | jd jƒS )Nr   )r   Zsource_expressionsÚoutput_fieldr,   r   r   r   r/   6   s    zArrayAgg.output_fieldN)
r&   r'   r(   ÚfunctionÚtemplateÚallow_distinctÚpropertyr!   r    r/   r   r   r   r   r
   (   s   ÿr
   c                   @   s   e Zd ZdZdS )r   ZBIT_ANDN©r&   r'   r(   r0   r   r   r   r   r   ;   s   r   c                   @   s   e Zd ZdZdS )r   ZBIT_ORNr4   r   r   r   r   r   ?   s   r   c                   @   s   e Zd ZdZeƒ ZdS )r   ZBOOL_ANDN©r&   r'   r(   r0   r   r/   r   r   r   r   r   C   s   r   c                   @   s   e Zd ZdZeƒ ZdS )r   ZBOOL_ORNr5   r   r   r   r   r   H   s   r   c                   @   s&   e Zd ZdZdZdZeƒ ZdZdZ	dS )r   Z	JSONB_AGGr*   Tz[]z×In Django 5.0, JSONBAgg() will return None instead of an empty list if there are no rows. Pass default=None to opt into the new behavior and silence this warning or default=Value('[]') to keep the previous behavior.N)
r&   r'   r(   r0   r1   r2   r   r/   r!   r    r   r   r   r   r   M   s   ÿr   c                       s0   e Zd ZdZdZdZdZdZ‡ fdd„Z‡  Z	S )r   Z
STRING_AGGr*   TÚ zØIn Django 5.0, StringAgg() will return None instead of an empty string if there are no rows. Pass default=None to opt into the new behavior and silence this warning or default=Value('') to keep the previous behavior.c                    s&   t t|ƒƒ}tƒ j||fi |¤Ž d S r+   )r   Ústrr   r   )r   r#   Ú	delimiterr   Zdelimiter_exprr   r   r   r   k   s    zStringAgg.__init__)
r&   r'   r(   r0   r1   r2   r!   r    r   r)   r   r   r   r   r   ]   s   ÿr   )r   Zdjango.contrib.postgres.fieldsr   Zdjango.db.modelsr   r   r   r   Zdjango.utils.deprecationr   Zmixinsr	   Ú__all__Úobjectr   r   r
   r   r   r   r   r   r   r   r   r   r   Ú<module>   s   