Ë
    V.jO7  ã                  óL  — 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j0                  «      Zd„ Zy)é    )ÚannotationsN)ÚAny)ÚOptional)ÚTypeVaré   )ÚCONTAINED_BY)ÚCONTAINS)ÚOVERLAPé   )Útypes)Úutil)Ú
expression)Ú	operators)Ú_TypeEngineArgumentÚ_T)Úboundc                ó&   — |j                  | |«      S )zjA synonym for the ARRAY-level :meth:`.ARRAY.Comparator.any` method.
    See that method for details.

    )Úany©ÚotherÚarrexprÚoperators      úfC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\sqlalchemy/dialects/postgresql/array.pyr   r      ó   € ð �;‰;�u˜hÓ'Ð'ó    c                ó&   — |j                  | |«      S )zjA synonym for the ARRAY-level :meth:`.ARRAY.Comparator.all` method.
    See that method for details.

    )Úallr   s      r   ÚAllr   '   r   r   c                  óN   ‡ — 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                óÖ  •— |j                  dd «      }t        ‰| �  t        j                  g|¢­i |¤Ž | j
                  D �cg c]  }|j                  ‘Œ c}| _        |�|n*| j                  r| j                  d   nt        j                  }t        |t        «      r8t        |j                  |j                  �|j                  dz   nd¬«      | _        y t        |«      | _        y c c}w )NÚtype_r   r   é   )Ú
dimensions)ÚpopÚsuperÚ__init__r   Úcomma_opÚclausesÚtypeÚ_type_tupleÚsqltypesÚNULLTYPEÚ
isinstanceÚARRAYÚ	item_typer%   )Úselfr*   ÚkwÚtype_argÚargÚ	main_typeÚ	__class__s         €r   r(   zarray.__init__g   sÔ   ø€ Ø—6‘6˜' 4Ó(ˆÜ‰Ñœ×+Ñ+Ð<¨gÒ<¸Ò<à04·²Ó=±¨˜CŸH›H°Ñ=ˆÔð Ð#ñ à(,×(8Ò(8�×!Ñ! !Ò$¼h×>OÑ>Oð 	ô �i¤Ô'ÜØ×#Ñ#ð !×+Ñ+Ð7ð ×(Ñ(¨1Ò,àôˆD�Iô ˜iÓ(ˆD�Iùò% >s   ÁC&c                ó   — | fS ©N© ©r2   s    r   Ú_select_iterablezarray._select_iterable   s	   € àˆwˆr   c                óÖ   — |s|t         j                  u r%t        j                  d |||| j                  d¬«      S t        |D �cg c]  }| j                  ||d|¬«      ‘Œ c}«      S c c}w )NT)Ú_compared_to_operatorr#   Ú_compared_to_typeÚunique)Ú_assume_scalarr#   )r   Úgetitemr   ÚBindParameterr+   r    Ú_bind_param)r2   r   ÚobjrA   r#   Úos         r   rD   zarray._bind_paramƒ   s‰   € Ù˜X¬×):Ñ):Ñ:Ü×+Ñ+ØØØ&.ØØ"&§)¡)Øôð ô ñ
 !ó	ñ !˜ð ×$Ñ$Ø  !°DÀð %õ ð !ñ	óð ùòs   ÁA&c                ó’   — |t         j                  t         j                  t         j                  fv rt	        j
                  | «      S | S r9   )r   Úany_opÚall_oprB   r   ÚGrouping)r2   Úagainsts     r   Ú
self_groupzarray.self_group˜   s9   € Ø”y×'Ñ'¬×)9Ñ)9¼9×;LÑ;LÐMÑMÜ×&Ñ& tÓ,Ð,àˆKr   )FNr9   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__visit_name__Ústringify_dialectÚinherit_cacher(   Úpropertyr<   rD   rL   Ú__classcell__)r7   s   @r   r    r    0   s>   ø„ ñ/ðb €Nà$ÐØ€Mô)ð0 ñó ðó÷*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y)r0   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.

    Nc                ó    — t        |t        «      rt        d«      ‚t        |t        «      r |«       }|| _        || _        || _        || _        y)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)r/   r0   Ú
ValueErrorr+   r1   Úas_tupler%   Úzero_indexes)r2   r1   rY   r%   rZ   s        r   r(   zARRAY.__init__ä   sQ   € ôN �i¤Ô'Üð?óð ô �i¤Ô&Ù!›ˆIØ"ˆŒØ ˆŒØ$ˆŒØ(ˆÕr   c                  ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ú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                óN   — | j                  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	   r-   ÚBoolean)r2   r   Úkwargss      r   ÚcontainszARRAY.Comparator.contains!  s   € ð —<‘<¤¨%¼X×=MÑ=M�<ÓNÐNr   c                óN   — | j                  t        |t        j                  ¬«      S )z„Boolean expression.  Test if elements are a proper subset of the
            elements of the argument array expression.
            r^   )r`   r   r-   ra   ©r2   r   s     r   Úcontained_byzARRAY.Comparator.contained_by*  s'   € ð —<‘<Ü˜e´×1AÑ1Að  ó ð r   c                óN   — | j                  t        |t        j                  ¬«      S )zuBoolean expression.  Test if array has elements in common with
            an argument array expression.
            r^   )r`   r
   r-   ra   re   s     r   ÚoverlapzARRAY.Comparator.overlap2  s   € ð —<‘<¤¨¼H×<LÑ<L�<ÓMÐMr   N)rM   rN   rO   rP   rc   rf   rh   r:   r   r   Ú
Comparatorr\     s   „ ñ	ò	Oò	ó	Nr   ri   c                ó   — | j                   S r9   )rY   r;   s    r   ÚhashablezARRAY.hashable:  s   € à�}‰}Ðr   c                ó   — t         S r9   )Úlistr;   s    r   Úpython_typezARRAY.python_type>  s   € äˆr   c                ó   — ||k(  S r9   r:   )r2   ÚxÚys      r   Úcompare_valueszARRAY.compare_valuesB  s   € Ø�A‰vˆr   c                óz   — t        | j                  t        j                  «      xr | j                  j                  S r9   )r/   r1   r-   ÚEnumÚnative_enumr;   s    r   Ú_against_native_enumzARRAY._against_native_enumE  s-   € ô �t—~‘~¤x§}¡}Ó5ò +Ø—‘×*Ñ*ð	
r   c                óz   ‡ ‡‡— ‰ j                   j                  |«      j                  |«      Š‰€y d„ Šˆˆ ˆfd„}|S )Nc                ó,   — ddj                  | «      › d�S )NzARRAY[z, Ú])Újoin)Úelementss    r   Úto_strz'ARRAY.literal_processor.<locals>.to_strS  s   € Ø˜DŸI™I hÓ/Ð0°Ð2Ð2r   c                óD   •— ‰j                  | ‰‰j                  ‰«      }|S r9   )Ú_apply_item_processorr%   )ÚvalueÚinnerÚ	item_procr2   r|   s     €€€r   Úprocessz(ARRAY.literal_processor.<locals>.processV  s'   ø€ Ø×.Ñ.Ø�y $§/¡/°6óˆEð ˆLr   )r1   Údialect_implÚliteral_processor)r2   Údialectr‚   r�   r|   s   `  @@r   r„   zARRAY.literal_processorL  sA   ú€ Ø—N‘N×/Ñ/°Ó8×JÑJØó
ˆ	ð ÐØò	3ö	ð ˆr   c                ój   ‡ ‡— ‰ j                   j                  |«      j                  |«      Šˆˆ fd„}|S )Nc                óP   •— | €| S ‰j                  | ‰‰j                  t        «      S r9   )r~   r%   rm   ©r   r�   r2   s    €€r   r‚   z%ARRAY.bind_processor.<locals>.processc  s-   ø€ Øˆ}Ø�à×1Ñ1Ø˜9 d§o¡o´tóð r   )r1   rƒ   Úbind_processor)r2   r…   r‚   r�   s   `  @r   r‰   zARRAY.bind_processor^  s1   ù€ Ø—N‘N×/Ñ/°Ó8×GÑGØó
ˆ	õ	ð ˆr   c                óÎ   ‡ ‡‡‡‡— ‰ j                   j                  |«      j                  ||«      Šˆˆ fd„}‰ j                  r"|Št	        j
                  d«      Šˆfd„Šˆˆfd„}|S )Nc                ó|   •— | €| S ‰j                  | ‰‰j                  ‰j                  r
t        «      S t        «      S r9   )r~   r%   rY   Útuplerm   rˆ   s    €€r   r‚   z'ARRAY.result_processor.<locals>.processr  sE   ø€ Øˆ}Ø�à×1Ñ1ØØØ—O‘OØ!Ÿ]š]”Eó	ð ô 15ó	ð r   z^{(.*)}$c                óZ   •— ‰j                  | «      j                  d«      }t        |«      S )Nr   )ÚmatchÚgroupÚ_split_enum_values)r   r€   Úpatterns     €r   Úhandle_raw_stringz1ARRAY.result_processor.<locals>.handle_raw_string�  s'   ø€ ØŸ™ eÓ,×2Ñ2°1Ó5�Ü)¨%Ó0Ð0r   c                óT   •— | €| S  ‰t        | t        «      r ‰| «      «      S | «      S r9   )r/   Ústr)r   r’   Úsuper_rps    €€r   r‚   z'ARRAY.result_processor.<locals>.process…  s?   ø€ Ø�=Ø �Lñ  ä! %¬Ô-ñ & eÓ,óð ð óð r   )r1   rƒ   Úresult_processorrv   ÚreÚcompile)r2   r…   Úcoltyper‚   r’   r�   r‘   r•   s   `   @@@@r   r–   zARRAY.result_processorm  s[   ü€ Ø—N‘N×/Ñ/°Ó8×IÑIØ�Wó
ˆ	õ		ð ×$Ò$ØˆHÜ—j‘j Ó-ˆGô1õ
ð ˆr   )FNF)r1   z_TypeEngineArgument[Any]rY   Úboolr%   zOptional[int]rZ   rš   )rM   rN   rO   rP   r(   r-   r0   ri   Úcomparator_factoryrT   rk   rn   rr   r   Úmemoized_propertyrv   r„   r‰   r–   r:   r   r   r0   r0   Ÿ   sµ   „ ñBðN Ø$(Ø"ð1)à+ð1)ð ð1)ð "ð	1)ð
 ó1)ôfN�X—^‘^×.Ñ.ô NðB $Ðàñó ðð ñó ðòð 
×Ññ
ó ð
òò$ó$r   r0   c                óf  — d| vr| r| j                  d«      S g S | j                  dd«      }|j                  dd«      }g }t        j                   d|«      }d}|D ]T  }|dk(  r| }Œ|r"|j                  |j                  dd«      «       Œ0|j	                  t        j
                  d	|«      «       ŒV |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€DØ�<‰<˜˜tÓ$€DØ€FÜ—‘˜ Ó&€IØ€IÛˆØ�#Š:Ø%˜‰IÙØ�M‰M˜#Ÿ+™+ o°sÓ;Õ<à�M‰Mœ"Ÿ*™* ^°SÓ9Õ:ð ð €Mr   )Ú
__future__r   r—   Útypingr   r   r   r   r   r	   r
   Ú r   r-   r   Úsqlr   Úsql._typingr   r   Úeqr   ÚExpressionClauseListr    r0   r�   r:   r   r   Ú<module>r³      sŠ   ðõ #ã 	Ý Ý Ý å #Ý Ý Ý !Ý Ý Ý Ý .ñ ˆT˜Ô€ð "+§¡ó (ð "+§¡ó (ôlˆJ×+Ñ+¨BÑ/ô lô^rˆH�N‰Nô rójr   