3
W­E^.  ã               @   s¾   d dl mZmZ d dlmZ d dlmZ ddlmZ dddd	d
ddgZ	G dd„ d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ƒZG dd„ deeƒZdS )é    )Ú
ArrayFieldÚ	JSONField)ÚValue)Ú	Aggregateé   )ÚOrderableAggMixinÚArrayAggÚBitAndÚBitOrÚBoolAndÚBoolOrÚJSONBAggÚ	StringAggc               @   s,   e Zd ZdZdZdZedd„ ƒZdd„ ZdS )	r   Z	ARRAY_AGGz6%(function)s(%(distinct)s%(expressions)s %(ordering)s)Tc             C   s   t | jd jƒS )Nr   )r   Zsource_expressionsÚoutput_field)Úself© r   úL/tmp/pip-build-78s3knkw/Django/django/contrib/postgres/aggregates/general.pyr      s    zArrayAgg.output_fieldc             C   s   |sg S |S )Nr   )r   ÚvalueÚ
expressionÚ
connectionr   r   r   Úconvert_value   s    zArrayAgg.convert_valueN)	Ú__name__Ú
__module__Ú__qualname__ÚfunctionÚtemplateÚallow_distinctÚpropertyr   r   r   r   r   r   r      s
   c               @   s   e Zd ZdZdS )r	   ZBIT_ANDN)r   r   r   r   r   r   r   r   r	      s   c               @   s   e Zd ZdZdS )r
   ZBIT_ORN)r   r   r   r   r   r   r   r   r
      s   c               @   s   e Zd ZdZdS )r   ZBOOL_ANDN)r   r   r   r   r   r   r   r   r   #   s   c               @   s   e Zd ZdZdS )r   ZBOOL_ORN)r   r   r   r   r   r   r   r   r   '   s   c               @   s   e Zd ZdZeƒ Zdd„ ZdS )r   Z	JSONB_AGGc             C   s   |sg S |S )Nr   )r   r   r   r   r   r   r   r   /   s    zJSONBAgg.convert_valueN)r   r   r   r   r   r   r   r   r   r   r   r   +   s   c                   s0   e Zd ZdZdZdZ‡ fdd„Zdd„ Z‡  ZS )r   Z
STRING_AGGz6%(function)s(%(distinct)s%(expressions)s %(ordering)s)Tc                s"   t t|ƒƒ}tƒ j||f|Ž d S )N)r   ÚstrÚsuperÚ__init__)r   r   Ú	delimiterÚextraZdelimiter_expr)Ú	__class__r   r   r    :   s    zStringAgg.__init__c             C   s   |sdS |S )NÚ r   )r   r   r   r   r   r   r   r   >   s    zStringAgg.convert_value)	r   r   r   r   r   r   r    r   Ú__classcell__r   r   )r#   r   r   5   s
   N)Zdjango.contrib.postgres.fieldsr   r   Zdjango.db.modelsr   Zdjango.db.models.aggregatesr   Zmixinsr   Ú__all__r   r	   r
   r   r   r   r   r   r   r   r   Ú<module>   s   
