§
    WøÁi¦5  ã                  ó>  — d dl mZ d dlZd dlmZ d dlmZ d dlmZ ddlmZ ddlm	Z	 dd	lm
Z
 d
dlmZ d
dlmZ d
dlmZ d
dlmZ d
dlmZ  ede¬¦  «        Zej        fd„Zej        fd„Z G d„ dej        e         ¦  «        Z G d„ dej        ¦  «        Zd„ ZdS )é    )ÚannotationsN)ÚAny)ÚOptional)ÚTypeVaré   )ÚCONTAINED_BY)ÚCONTAINS)ÚOVERLAPé   )Útypes)Úutil)Ú
expression)Ú	operators)Ú_TypeEngineArgumentÚ_T)Úboundc                ó.   — |                      | |¦  «        S )zjA synonym for the ARRAY-level :meth:`.ARRAY.Comparator.any` method.
    See that method for details.

    )Úany©ÚotherÚarrexprÚoperators      ún/var/www/html/jarvis.com/web/backend/venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/array.pyr   r      ó   € ð �;Š;�u˜hÑ'Ô'Ð'ó    c                ó.   — |                      | |¦  «        S )zjA synonym for the ARRAY-level :meth:`.ARRAY.Comparator.all` method.
    See that method for details.

    )Úallr   s      r   ÚAllr   '   r   r   c                  óT   ‡ — e Zd ZdZd ZdZdZˆ fd„Zed„ ¦   «         Z	d
d„Z
dd	„Zˆ xZS )Úarraya×  A PostgreSQL ARRAY literal.

    This is used to produce ARRAY literals in SQL expressions, e.g.::

        from sqlalchemy.dialects.postgresql import array
        from sqlalchemy.dialects import postgresql
        from sqlalchemy import select, func

        stmt = select(array([1,2]) + array([3,4,5]))

        print(stmt.compile(dialect=postgresql.dialect()))

    Produces the SQL::

        SELECT ARRAY[%(param_1)s, %(param_2)s] ||
            ARRAY[%(param_3)s, %(param_4)s, %(param_5)s]) AS anon_1

    An instance of :class:`.array` will always have the datatype
    :class:`_types.ARRAY`.  The "inner" type of the array is inferred from
    the values present, unless the ``type_`` keyword argument is passed::

        array(['foo', 'bar'], type_=CHAR)

    Multidimensional arrays are produced by nesting :class:`.array` constructs.
    The dimensionality of the final :class:`_types.ARRAY`
    type is calculated by
    recursively adding the dimensions of the inner :class:`_types.ARRAY`
    type::

        stmt = select(
            array([
                array([1, 2]), array([3, 4]), array([column('q'), column('x')])
            ])
        )
        print(stmt.compile(dialect=postgresql.dialect()))

    Produces::

        SELECT ARRAY[ARRAY[%(param_1)s, %(param_2)s],
        ARRAY[%(param_3)s, %(param_4)s], ARRAY[q, x]] AS anon_1

    .. versionadded:: 1.3.6 added support for multidimensional array literals

    .. seealso::

        :class:`_postgresql.ARRAY`

    Ú
postgresqlTc                ó¤  •— |                      dd ¦  «        } t          ¦   «         j        t          j        g|¢R i |¤Ž d„ | j        D ¦   «         | _        |�|n| j        r| j        d         nt          j        }t          |t          ¦  «        r.t          |j        |j        �
|j        dz   nd¬¦  «        | _        d S t          |¦  «        | _        d S )NÚtype_c                ó   — g | ]	}|j         ‘Œ
S © )Útype)Ú.0Úargs     r   ú
<listcomp>z"array.__init__.<locals>.<listcomp>k   s   € Ð=Ð=Ð=¨˜CœHÐ=Ð=Ð=r   r   r   é   )Ú
dimensions)ÚpopÚsuperÚ__init__r   Úcomma_opÚclausesÚ_type_tupleÚsqltypesÚNULLTYPEÚ
isinstanceÚARRAYÚ	item_typer+   r&   )Úselfr0   ÚkwÚtype_argÚ	main_typeÚ	__class__s        €r   r.   zarray.__init__g   sî   ø€ Ø—6’6˜' 4Ñ(Ô(ˆØ�‰ŒÔ�Ô+Ð<¨gÐ<Ð<Ð<¸Ð<Ð<Ð<à=Ð=°´Ð=Ñ=Ô=ˆÔð Ð#ð ˆHà(,Ô(8ÐO�Ô! !Ô$Ð$½hÔ>Oð 	õ �i¥Ñ'Ô'ð 
	)ÝØÔ#ð !Ô+Ð7ð Ô(¨1Ñ,Ð,àðñ ô ˆDŒIˆIˆIõ ˜iÑ(Ô(ˆDŒIˆIˆIr   c                ó   — | fS ©Nr%   ©r7   s    r   Ú_select_iterablezarray._select_iterable   s	   € àˆwˆr   FNc                ó    ‡ ‡‡— |s‰t           j        u rt          j        d |‰‰‰ j        d¬¦  «        S t          ˆˆ ˆfd„|D ¦   «         ¦  «        S )NT)Ú_compared_to_operatorr#   Ú_compared_to_typeÚuniquec                óB   •— g | ]}‰                      ‰|d ‰¬¦  «        ‘ŒS )T)Ú_assume_scalarr#   )Ú_bind_param)r'   Úor   r7   r#   s     €€€r   r)   z%array._bind_param.<locals>.<listcomp>�   sI   ø€ ð ð ð ð ð ×$Ò$Ø  !°DÀð %ñ ô ðð ð r   )r   Úgetitemr   ÚBindParameterr&   r    )r7   r   ÚobjrE   r#   s   ``  `r   rF   zarray._bind_paramƒ   sŽ   øøø€ Øð 	˜X­Ô):Ð:Ð:ÝÔ+ØØØ&.ØØ"&¤)Øðñ ô ð õ ðð ð ð ð ð ð !ð	ñ ô ñô ð r   c                óx   — |t           j        t           j        t           j        fv rt	          j        | ¦  «        S | S r=   )r   Úany_opÚall_oprH   r   ÚGrouping)r7   Úagainsts     r   Ú
self_groupzarray.self_group˜   s3   € Ø•yÔ'­Ô)9½9Ô;LÐMÐMÐMÝÔ& tÑ,Ô,Ð,àˆKr   )FNr=   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__visit_name__Ústringify_dialectÚinherit_cacher.   Úpropertyr?   rF   rP   Ú__classcell__)r;   s   @r   r    r    0   s˜   ø€ € € € € ð/ð /ðb €Nà$ÐØ€Mð)ð )ð )ð )ð )ð0 ðð ñ „Xððð ð ð ð*ð ð ð ð ð ð ð r   r    c                  óº   — e Zd ZdZ	 	 	 ddd„Z G d„ dej        j        ¦  «        ZeZe	d„ ¦   «         Z
e	d„ ¦   «         Zd„ Zej        d„ ¦   «         Zd„ Zd„ Zd„ ZdS )r5   a[
  PostgreSQL ARRAY type.

    The :class:`_postgresql.ARRAY` type is constructed in the same way
    as the core :class:`_types.ARRAY` type; a member type is required, and a
    number of dimensions is recommended if the type is to be used for more
    than one dimension::

        from sqlalchemy.dialects import postgresql

        mytable = Table("mytable", metadata,
                Column("data", postgresql.ARRAY(Integer, dimensions=2))
            )

    The :class:`_postgresql.ARRAY` type provides all operations defined on the
    core :class:`_types.ARRAY` type, including support for "dimensions",
    indexed access, and simple matching such as
    :meth:`.types.ARRAY.Comparator.any` and
    :meth:`.types.ARRAY.Comparator.all`.  :class:`_postgresql.ARRAY`
    class also
    provides PostgreSQL-specific methods for containment operations, including
    :meth:`.postgresql.ARRAY.Comparator.contains`
    :meth:`.postgresql.ARRAY.Comparator.contained_by`, and
    :meth:`.postgresql.ARRAY.Comparator.overlap`, e.g.::

        mytable.c.data.contains([1, 2])

    Indexed access is one-based by default, to match that of PostgreSQL;
    for zero-based indexed access, set
    :paramref:`_postgresql.ARRAY.zero_indexes`.

    Additionally, the :class:`_postgresql.ARRAY`
    type does not work directly in
    conjunction with the :class:`.ENUM` type.  For a workaround, see the
    special type at :ref:`postgresql_array_of_enum`.

    .. container:: topic

        **Detecting Changes in ARRAY columns when using the ORM**

        The :class:`_postgresql.ARRAY` type, when used with the SQLAlchemy ORM,
        does not detect in-place mutations to the array. In order to detect
        these, the :mod:`sqlalchemy.ext.mutable` extension must be used, using
        the :class:`.MutableList` class::

            from sqlalchemy.dialects.postgresql import ARRAY
            from sqlalchemy.ext.mutable import MutableList

            class SomeOrmClass(Base):
                # ...

                data = Column(MutableList.as_mutable(ARRAY(Integer)))

        This extension will allow "in-place" changes such to the array
        such as ``.append()`` to produce events which will be detected by the
        unit of work.  Note that changes to elements **inside** the array,
        including subarrays that are mutated in place, are **not** detected.

        Alternatively, assigning a new array value to an ORM element that
        replaces the old one will always trigger a change event.

    .. seealso::

        :class:`_types.ARRAY` - base array type

        :class:`_postgresql.array` - produces a literal array value.

    FNr6   ú_TypeEngineArgument[Any]Úas_tupleÚboolr+   úOptional[int]Úzero_indexesc                óÄ   — t          |t          ¦  «        rt          d¦  «        ‚t          |t          ¦  «        r
 |¦   «         }|| _        || _        || _        || _        dS )a-  Construct an ARRAY.

        E.g.::

          Column('myarray', ARRAY(Integer))

        Arguments are:

        :param item_type: The data type of items of this array. Note that
          dimensionality is irrelevant here, so multi-dimensional arrays like
          ``INTEGER[][]``, are constructed as ``ARRAY(Integer)``, not as
          ``ARRAY(ARRAY(Integer))`` or such.

        :param as_tuple=False: Specify whether return results
          should be converted to tuples from lists. DBAPIs such
          as psycopg2 return lists by default. When tuples are
          returned, the results are hashable.

        :param dimensions: if non-None, the ARRAY will assume a fixed
         number of dimensions.  This will cause the DDL emitted for this
         ARRAY to include the exact number of bracket clauses ``[]``,
         and will also optimize the performance of the type overall.
         Note that PG arrays are always implicitly "non-dimensioned",
         meaning they can store any number of dimensions no matter how
         they were declared.

        :param zero_indexes=False: when True, index values will be converted
         between Python zero-based and PostgreSQL one-based indexes, e.g.
         a value of one will be added to all index values before passing
         to the database.

        zUDo not nest ARRAY types; ARRAY(basetype) handles multi-dimensional arrays of basetypeN)r4   r5   Ú
ValueErrorr&   r6   r\   r+   r_   )r7   r6   r\   r+   r_   s        r   r.   zARRAY.__init__ä   sp   € õN �i¥Ñ'Ô'ð 	Ýð?ñô ð õ �i¥Ñ&Ô&ð 	$Ø!˜	™œˆIØ"ˆŒØ ˆŒØ$ˆŒØ(ˆÔÐÐr   c                  ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )úARRAY.Comparatora*  Define comparison operations for :class:`_types.ARRAY`.

        Note that these operations are in addition to those provided
        by the base :class:`.types.ARRAY.Comparator` class, including
        :meth:`.types.ARRAY.Comparator.any` and
        :meth:`.types.ARRAY.Comparator.all`.

        c                óP   — |                       t          |t          j        ¬¦  «        S )zåBoolean expression.  Test if elements are a superset of the
            elements of the argument array expression.

            kwargs may be ignored by this operator but are required for API
            conformance.
            ©Úresult_type)Úoperater	   r2   ÚBoolean)r7   r   Úkwargss      r   ÚcontainszARRAY.Comparator.contains!  s   € ð —<’<¥¨%½XÔ=M�<ÑNÔNÐNr   c                óP   — |                       t          |t          j        ¬¦  «        S )z„Boolean expression.  Test if elements are a proper subset of the
            elements of the argument array expression.
            re   )rg   r   r2   rh   ©r7   r   s     r   Úcontained_byzARRAY.Comparator.contained_by*  s)   € ð —<’<Ý˜eµÔ1Að  ñ ô ð r   c                óP   — |                       t          |t          j        ¬¦  «        S )zuBoolean expression.  Test if array has elements in common with
            an argument array expression.
            re   )rg   r
   r2   rh   rl   s     r   ÚoverlapzARRAY.Comparator.overlap2  s   € ð —<’<¥¨½HÔ<L�<ÑMÔMÐMr   N)rQ   rR   rS   rT   rj   rm   ro   r%   r   r   Ú
Comparatorrc     sS   € € € € € ð	ð 	ð	Oð 	Oð 	Oð	ð 	ð 	ð	Nð 	Nð 	Nð 	Nð 	Nr   rp   c                ó   — | j         S r=   )r\   r>   s    r   ÚhashablezARRAY.hashable:  s
   € àŒ}Ðr   c                ó   — t           S r=   )Úlistr>   s    r   Úpython_typezARRAY.python_type>  s   € åˆr   c                ó   — ||k    S r=   r%   )r7   ÚxÚys      r   Úcompare_valueszARRAY.compare_valuesB  s   € Ø�AŠvˆr   c                óX   — t          | j        t          j        ¦  «        o| j        j        S r=   )r4   r6   r2   ÚEnumÚnative_enumr>   s    r   Ú_against_native_enumzARRAY._against_native_enumE  s'   € õ �t”~¥x¤}Ñ5Ô5ð +Ø”Ô*ð	
r   c                ó‚   ‡ ‡‡— ‰ j                              |¦  «                             |¦  «        Š‰€d S d„ Šˆˆ ˆfd„}|S )Nc                ó4   — dd                      | ¦  «        › d�S )NzARRAY[z, ú])Újoin)Úelementss    r   Úto_strz'ARRAY.literal_processor.<locals>.to_strS  s   € Ø2˜DŸIšI hÑ/Ô/Ð2Ð2Ð2Ð2r   c                óB   •— ‰                      | ‰‰j        ‰¦  «        }|S r=   )Ú_apply_item_processorr+   )ÚvalueÚinnerÚ	item_procr7   rƒ   s     €€€r   Úprocessz(ARRAY.literal_processor.<locals>.processV  s*   ø€ Ø×.Ò.Ø�y $¤/°6ñô ˆEð ˆLr   )r6   Údialect_implÚliteral_processor)r7   Údialectr‰   rˆ   rƒ   s   `  @@r   r‹   zARRAY.literal_processorL  ss   øøø€ Ø”N×/Ò/°Ñ8Ô8×JÒJØñ
ô 
ˆ	ð ÐØ�4ð	3ð 	3ð 	3ð	ð 	ð 	ð 	ð 	ð 	ð 	ð ˆr   c                óp   ‡ ‡— ‰ j                              |¦  «                             |¦  «        Šˆˆ fd„}|S )Nc                óP   •— | €| S ‰                      | ‰‰j        t          ¦  «        S r=   )r…   r+   rt   ©r†   rˆ   r7   s    €€r   r‰   z%ARRAY.bind_processor.<locals>.processc  s0   ø€ Øˆ}Ø�à×1Ò1Ø˜9 d¤oµtñô ð r   )r6   rŠ   Úbind_processor)r7   rŒ   r‰   rˆ   s   `  @r   r�   zARRAY.bind_processor^  sQ   øø€ Ø”N×/Ò/°Ñ8Ô8×GÒGØñ
ô 
ˆ	ð	ð 	ð 	ð 	ð 	ð 	ð ˆr   c                óÈ   ‡ ‡‡‡‡— ‰ j                              |¦  «                             ||¦  «        Šˆˆ fd„}‰ j        r!|Št	          j        d¦  «        Šˆfd„Šˆˆfd„}|S )Nc                ól   •— | €| S ‰                      | ‰‰j        ‰j        rt          nt          ¦  «        S r=   )r…   r+   r\   Útuplert   r�   s    €€r   r‰   z'ARRAY.result_processor.<locals>.processr  s>   ø€ Øˆ}Ø�à×1Ò1ØØØ”OØ!œ]Ð4•E�Eµñ	ô ð r   z^{(.*)}$c                ór   •— ‰                      | ¦  «                             d¦  «        }t          |¦  «        S )Nr   )ÚmatchÚgroupÚ_split_enum_values)r†   r‡   Úpatterns     €r   Úhandle_raw_stringz1ARRAY.result_processor.<locals>.handle_raw_string�  s0   ø€ ØŸš eÑ,Ô,×2Ò2°1Ñ5Ô5�Ý)¨%Ñ0Ô0Ð0r   c                ób   •— | €| S  ‰t          | t          ¦  «        r ‰| ¦  «        n| ¦  «        S r=   )r4   Ústr)r†   r™   Úsuper_rps    €€r   r‰   z'ARRAY.result_processor.<locals>.process…  sI   ø€ Ø�=Ø �Lð  �xå! %­Ñ-Ô-ðÐ%Ð% eÑ,Ô,Ð,àñô ð r   )r6   rŠ   Úresult_processorr}   ÚreÚcompile)r7   rŒ   Úcoltyper‰   r™   rˆ   r˜   rœ   s   `   @@@@r   r�   zARRAY.result_processorm  s®   øøøøø€ Ø”N×/Ò/°Ñ8Ô8×IÒIØ�Wñ
ô 
ˆ	ð		ð 		ð 		ð 		ð 		ð 		ð Ô$ð 	ØˆHÝ”j Ñ-Ô-ˆGð1ð 1ð 1ð 1ð 1ð
ð 
ð 
ð 
ð 
ð 
ð ˆr   )FNF)r6   r[   r\   r]   r+   r^   r_   r]   )rQ   rR   rS   rT   r.   r2   r5   rp   Úcomparator_factoryrX   rr   ru   ry   r   Úmemoized_propertyr}   r‹   r�   r�   r%   r   r   r5   r5   Ÿ   s  € € € € € ðBð BðN Ø$(Ø"ð1)ð 1)ð 1)ð 1)ð 1)ðfNð Nð Nð Nð N�X”^Ô.ñ Nô Nð NðB $Ðàðð ñ „Xðð ðð ñ „Xððð ð ð 
Ôð
ð 
ñ Ôð
ðð ð ð$ð ð ð$ð $ð $ð $ð $r   r5   c                ó�  — d| vr| r|                       d¦  «        ng S |                      dd¦  «        }|                     dd¦  «        }g }t          j         d|¦  «        }d}|D ]`}|dk    r| }Œ|r*|                     |                     dd¦  «        ¦  «         Œ8|                     t          j        d	|¦  «        ¦  «         Œa|S )
Nú"ú,z\"z_$ESC_QUOTE$_z\\ú\z(")Fz([^\s,]+),?)ÚsplitÚreplacerž   ÚappendÚextendÚfindall)Úarray_stringÚtextÚresultÚ	on_quotesÚ	in_quotesÚtoks         r   r—   r—   ”  sâ   € Ø
�,ÐÐà*6Ð>ˆ|×!Ò! #Ñ&Ô&Ð&¸BÐ>ð ×Ò  Ñ7Ô7€DØ�<Š<˜˜tÑ$Ô$€DØ€FÝ”˜ Ñ&Ô&€IØ€IØð ;ð ;ˆØ�#Š:ˆ:Ø%˜ˆIˆIØð 	;Ø�MŠM˜#Ÿ+š+ o°sÑ;Ô;Ñ<Ô<Ð<Ð<à�MŠM�"œ* ^°SÑ9Ô9Ñ:Ô:Ð:Ð:Ø€Mr   )Ú
__future__r   rž   Útypingr   r   r   r   r   r	   r
   Ú r   r2   r   Úsqlr   Úsql._typingr   r   Úeqr   ÚExpressionClauseListr    r5   r—   r%   r   r   ú<module>r¹      s½  ðð #Ð "Ð "Ð "Ð "Ð "à 	€	€	€	Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .ð €WˆT˜ÐÑÔ€ð "+¤ð (ð (ð (ð (ð "+¤ð (ð (ð (ð (ðlð lð lð lð lˆJÔ+¨BÔ/ñ lô lð lð^rð rð rð rð rˆHŒNñ rô rð rðjð ð ð ð r   