HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyc
�
���ec@s ddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	ej
d	�Zej
d
�Zdej
ejfd��YZejd
ddde�Zejdddde�Zejdddde�Zdejfd��YZd�ZdS(i����Ni(ttypes(tutil(t	coercions(t
expression(t	operators(trolescCs|j||�S(sjA synonym for the ARRAY-level :meth:`.ARRAY.Comparator.any` method.
    See that method for details.

    (tany(tothertarrexprtoperator((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytAnyscCs|j||�S(sjA synonym for the ARRAY-level :meth:`.ARRAY.Comparator.all` method.
    See that method for details.

    (tall(RRR	((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytAllstarraycBsSeZdZdZdZeZd�Zed��Z	e
dd�Zdd�Z
RS(s�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`

    R
t
postgresqlcKs�g|D]}tjtj|�^q}tt|�j||�g|D]}|j^qH|_|j	d|jr|jdnt
j�}t|t
�r�t
|jd|jdk	r�|jdnd�|_nt
|�|_dS(Nttype_it
dimensionsii(RtexpectRtExpressionElementRoletsuperR
t__init__ttypet_type_tupletpoptsqltypestNULLTYPEt
isinstancetARRAYt	item_typeRtNone(tselftclausestkwtctargt	main_type((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR\s("	cCs|fS(N((R((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt_select_iterablesscCsy|s|tjkr@tjd|d|d|d|jdt�Stg|D]$}|j||dtd|�^qJ�SdS(Nt_compared_to_operatorRt_compared_to_typetuniquet_assume_scalar(	RtgetitemRt
BindParameterRRtTrueR
t_bind_param(RR	tobjR(Rto((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR,ws	cCs3|tjtjtjfkr+tj|�S|SdS(N(Rtany_optall_opR)RtGrouping(Rtagainst((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt
self_group�s
N(t__name__t
__module__t__doc__t__visit_name__tstringify_dialectR+t
inherit_cacheRtpropertyR$tFalseRR,R3(((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR
$s1	s@>t
precedenceit
is_comparisons<@s&&RcBs�eZdZdejjfd��YZeZeded�Z	e
d��Ze
d��Zd�Z
d�Zejd��Zd	�Zd
�Zd�ZRS(
s�
PostgreSQL ARRAY type.

    .. versionchanged:: 1.1 The :class:`_postgresql.ARRAY` type is now
       a subclass of the core :class:`_types.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])

    The :class:`_postgresql.ARRAY` type may not be supported on all
    PostgreSQL DBAPIs; it is currently known to work on psycopg2 only.

    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.

    t
ComparatorcBs)eZdZd�Zd�Zd�ZRS(s*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`.

        cKs|jt|dtj�S(s�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.
            tresult_type(toperatetCONTAINSRtBoolean(RRtkwargs((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytcontains�scCs|jt|dtj�S(s�Boolean expression.  Test if elements are a proper subset of the
            elements of the argument array expression.
            R?(R@tCONTAINED_BYRRB(RR((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytcontained_by�scCs|jt|dtj�S(suBoolean expression.  Test if array has elements in common with
            an argument array expression.
            R?(R@tOVERLAPRRB(RR((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytoverlap�s(R4R5R6RDRFRH(((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR>�s				cCsat|t�rtd��nt|t�r9|�}n||_||_||_||_dS(sPConstruct 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.

         .. versionadded:: 0.9.5


        sUDo not nest ARRAY types; ARRAY(basetype) handles multi-dimensional arrays of basetypeN(RRt
ValueErrorRRtas_tupleRtzero_indexes(RRRJRRK((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyRs&			cCs|jS(N(RJ(R((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pythashable8scCstS(N(tlist(R((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytpython_type<scCs
||kS(N((Rtxty((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytcompare_values@scs��dkrt|�}n�dksT�dkr�|sTt|dttf�r��rt��fd�|D��S�|�Sn#�����fd�|D��SdS(Niic3s|]}�|�VqdS(N((t.0RO(titemproc(sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pys	<genexpr>Rsc3s=|]3}�j|��dk	r+�dnd��VqdS(iN(t_proc_arrayR(RRRO(t
collectiontdimRSR(sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pys	<genexpr>Ws(RRMRttuple(RtarrRSRVRU((RURVRSRsU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyRTCs
cCst|jtj�o|jjS(N(RRRtEnumtnative_enum(R((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt_against_native_enum`scCs|S(N((Rt	bindvalue((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytbind_expressiongscs1�jj|�j|����fd�}|S(Ncs-|dkr|S�j|��jt�SdS(N(RRTRRM(tvalue(t	item_procR(sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pytprocessos(Rtdialect_impltbind_processor(RtdialectR`((R_RsU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyRbjs	csv�jj|�j||����fd�}�jrr|�tjd���fd����fd�}n|S(Ncs<|dkr|S�j|��j�jr1tnt�SdS(N(RRTRRJRWRM(R^(R_R(sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR`~ss^{(.*)}$cs"�j|�jd�}t|�S(Ni(tmatchtgroupt_split_enum_values(R^tinner(tpattern(sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pythandle_raw_string�scs8|dkr|S�t|tj�r1�|�n|�S(N(RRRtstring_types(R^(Ritsuper_rp(sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR`�s
(RRatresult_processorR[tretcompile(RRctcoltypeR`((RiR_RhRRksU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyRlys	N(R4R5R6RRR>tcomparator_factoryR;RRR:RLRNRQRTRtmemoized_propertyR[R]RbRl(((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR�sF"1				cCs�d|kr#|r|jd�SgS|jdd�}|jdd�}g}tjd|�}t}x_|D]W}|dkr�|}ql|r�|j|jdd��ql|jtjd|��qlW|S(	Nt"t,s\"s
_$ESC_QUOTE$_s\\s\s(")s([^\s,]+),?(tsplittreplaceRmR;tappendtextendtfindall(tarray_stringttexttresultt	on_quotest	in_quotesttok((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyRf�s

(RmtRRRtsqlRRRRteqR
Rt
ClauseListt
ColumnElementR
t	custom_opR+RARERGRRf(((sU/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt<module>s		o�