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/hstore.pyc
�
���ec@snddlZddlmZddlmZddlmZddlmZ	ddlm
Z
d)Ze
je
j
Ze
jdded
ede�Ze
jdded
ede�Ze
jdded
ede�Ze
jdded
ede�Ze
jdded
ede�Ze
jdded
ede�Zd	ejejejfd��YZd
e	jfd��YZde	jfd��YZde	jfd��YZde	jfd��YZde	jfd��YZ de	jfd��YZ!d e	jfd!��YZ"d"e	jfd#��YZ#ej$d$ej%�Z&ej$d%ej%�Z'd&�Z(d'�Z)d(�Z*dS(*i����Ni(tARRAYi(ttypes(tutil(t	functions(t	operatorstHSTOREthstores->t
precedencetnatural_self_precedentteager_groupingt?s?&s?|s@>s<@cBsoeZdZdZeZej�Zdd�Z
dejjej
jfd��YZeZd�Zd�ZRS(s%	Represent the PostgreSQL HSTORE type.

    The :class:`.HSTORE` type stores dictionaries containing strings, e.g.::

        data_table = Table('data_table', metadata,
            Column('id', Integer, primary_key=True),
            Column('data', HSTORE)
        )

        with engine.connect() as conn:
            conn.execute(
                data_table.insert(),
                data = {"key1": "value1", "key2": "value2"}
            )

    :class:`.HSTORE` provides for a wide range of operations, including:

    * Index operations::

        data_table.c.data['some key'] == 'some value'

    * Containment operations::

        data_table.c.data.has_key('some key')

        data_table.c.data.has_all(['one', 'two', 'three'])

    * Concatenation::

        data_table.c.data + {"k1": "v1"}

    For a full list of special methods see
    :class:`.HSTORE.comparator_factory`.

    .. container:: topic

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

        For usage with the SQLAlchemy ORM, it may be desirable to combine the
        usage of :class:`.HSTORE` with :class:`.MutableDict` dictionary now
        part of the :mod:`sqlalchemy.ext.mutable` extension. This extension
        will allow "in-place" changes to the dictionary, e.g. addition of new
        keys or replacement/removal of existing keys to/from the current
        dictionary, to produce events which will be detected by the unit of
        work::

            from sqlalchemy.ext.mutable import MutableDict

            class MyClass(Base):
                __tablename__ = 'data_table'

                id = Column(Integer, primary_key=True)
                data = Column(MutableDict.as_mutable(HSTORE))

            my_object = session.query(MyClass).one()

            # in-place mutation, requires Mutable extension
            # in order for the ORM to detect
            my_object.data['some_key'] = 'some value'

            session.commit()

        When the :mod:`sqlalchemy.ext.mutable` extension is not used, the ORM
        will not be alerted to any changes to the contents of an existing
        dictionary, unless that dictionary value is re-assigned to the
        HSTORE-attribute itself, thus generating a change event.

    .. seealso::

        :class:`.hstore` - render the PostgreSQL ``hstore()`` function.


    RcCs|dk	r||_ndS(s�Construct a new :class:`.HSTORE`.

        :param text_type: the type that should be used for indexed values.
         Defaults to :class:`_types.Text`.

         .. versionadded:: 1.1.0

        N(tNonet	text_type(tselfR((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyt__init__�s	t
ComparatorcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZRS(s2Define comparison operations for :class:`.HSTORE`.cCs|jt|dtj�S(svBoolean expression.  Test for presence of a key.  Note that the
            key may be a SQLA expression.
            tresult_type(toperatetHAS_KEYtsqltypestBoolean(R
tother((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pythas_key�scCs|jt|dtj�S(s;Boolean expression.  Test for presence of all keys in jsonbR(RtHAS_ALLRR(R
R((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pythas_all�scCs|jt|dtj�S(s:Boolean expression.  Test for presence of any key in jsonbR(RtHAS_ANYRR(R
R((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pythas_any�scKs|jt|dtj�S(s�Boolean expression.  Test if keys (or array) are a superset
            of/contained the keys of the argument jsonb expression.

            kwargs may be ignored by this operator but are required for API
            conformance.
            R(RtCONTAINSRR(R
Rtkwargs((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytcontains�scCs|jt|dtj�S(s|Boolean expression.  Test if keys are a proper subset of the
            keys of the argument jsonb expression.
            R(RtCONTAINED_BYRR(R
R((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytcontained_by�scCst||jjfS(N(tGETITEMttypeR(R
tindex((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyt_setup_getitem�scCst|j|�S(s�Boolean expression.  Test for presence of a non-NULL value for
            the key.  Note that the key may be a SQLA expression.
            (t_HStoreDefinedFunctiontexpr(R
tkey((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytdefined�scCs.t|t�rt|�}nt|j|�S(s�HStore expression.  Returns the contents of this hstore with the
            given key deleted.  Note that the key may be a SQLA expression.
            (t
isinstancetdictt_serialize_hstoret_HStoreDeleteFunctionR%(R
R&((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytdelete�scCst|j|�S(sdHStore expression.  Returns a subset of an hstore defined by
            array of keys.
            (t_HStoreSliceFunctionR%(R
tarray((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytslice�scCs
t|j�S(s.Text array expression.  Returns array of keys.(t_HStoreKeysFunctionR%(R
((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytkeys�scCs
t|j�S(s0Text array expression.  Returns array of values.(t_HStoreValsFunctionR%(R
((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytvals�scCs
t|j�S(s^Text array expression.  Returns array of alternating keys and
            values.
            (t_HStoreArrayFunctionR%(R
((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR.�scCs
t|j�S(s<Text array expression.  Returns array of [key, value] pairs.(t_HStoreMatrixFunctionR%(R
((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytmatrix�s(t__name__t
__module__t__doc__RRRRRR#R'R,R/R1R3R.R6(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR�s													cs1tjr$|j��fd�}n	d�}|S(Ncs*t|t�r"t|�j��S|SdS(N(R(R)R*tencode(tvalue(tencoding(sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytprocess�scSs!t|t�rt|�S|SdS(N(R(R)R*(R;((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR=�s
(Rtpy2kR<(R
tdialectR=((R<sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytbind_processor�s
			cs1tjr$|j��fd�}n	d�}|S(Ncs'|dk	rt|j���S|SdS(N(Rt
_parse_hstoretdecode(R;(R<(sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR=scSs|dk	rt|�S|SdS(N(RRA(R;((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR=
s
(RR>R<(R
R?tcoltypeR=((R<sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytresult_processor�s
			N(R7R8R9t__visit_name__tFalsethashableRtTextRRRt	IndexableRtConcatenabletcomparator_factoryR@RD(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR@sI"L	cBs eZdZeZdZeZRS(sGConstruct an hstore value within a SQL expression using the
    PostgreSQL ``hstore()`` function.

    The :class:`.hstore` function accepts one or two arguments as described
    in the PostgreSQL documentation.

    E.g.::

        from sqlalchemy.dialects.postgresql import array, hstore

        select(hstore('key1', 'value1'))

        select(
            hstore(
                array(['key1', 'key2', 'key3']),
                array(['value1', 'value2', 'value3'])
            )
        )

    .. seealso::

        :class:`.HSTORE` - the PostgreSQL ``HSTORE`` datatype.

    R(R7R8R9RR!tnametTruet
inherit_cache(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyRsR$cBseZejZdZeZRS(R'(R7R8RRR!RLRMRN(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR$2s	R+cBseZeZdZeZRS(R,(R7R8RR!RLRMRN(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR+8sR-cBseZeZdZeZRS(R/(R7R8RR!RLRMRN(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR->sR0cBs#eZeej�ZdZeZRS(takeys(	R7R8RRRHR!RLRMRN(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR0DsR2cBs#eZeej�ZdZeZRS(tavals(	R7R8RRRHR!RLRMRN(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR2JsR4cBs#eZeej�ZdZeZRS(thstore_to_array(	R7R8RRRHR!RLRMRN(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR4PsR5cBs#eZeej�ZdZeZRS(thstore_to_matrix(	R7R8RRRHR!RLRMRN(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR5Vss�
(
  "(?P<key> (\\ . | [^"])* )"       # Quoted key
)
[ ]* => [ ]*    # Pair operator, optional adjoining whitespace
(
    (?P<value_null> NULL )          # NULL value
  | "(?P<value> (\\ . | [^"])* )"   # Quoted value
)
s

[ ]* , [ ]*
cCs�d}t|�}|t||dd�t||�!}|t||�t||d|�!}t|�|kr�d|d}nt|�|kr�|d d}nd|||fS(sformat an unmarshalling error.iiis[...]i����s5After %r, could not parse residual at position %d: %r(tlentmaxtmin(t
hstore_strtpostctxthslentparsed_tailtresidual((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyt_parse_errorzs''cCs!i}d}tj|�}x�|d	k	r�|jd�jdd�jdd�}|jd�rid	}n'|jd�jdd�jdd�}|||<||j�7}tj||�}|d	k	r�||j�7}ntj||�}qW|t|�krtt	||���n|S(
s�Parse an hstore from its literal string representation.

    Attempts to approximate PG's hstore input parsing rules as closely as
    possible. Although currently this is not strictly necessary, since the
    current implementation of hstore's output syntax is stricter than what it
    accepts as input, the documentation makes no guarantees that will always
    be the case.



    iR&s\"t"s\\s\t
value_nullR;N(
tHSTORE_PAIR_REtmatchRtgrouptreplacetendtHSTORE_DELIMITER_RERSt
ValueErrorR\(RVtresultRWt
pair_matchR&R;tdelim_match((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyRA�s&'	
cs,d��dj�fd�|j�D��S(sxSerialize a dictionary into an hstore literal.  Keys and values must
    both be strings (except None for values).

    cSsh|dkr|dkrdSt|tj�rNd|jdd�jdd�Std||f��dS(	NR;tNULLs"%s"s\s\\R]s\"s"%r in %s position is not a string.(RR(Rtstring_typesRbRe(tstposition((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pytesc�s s, c3s7|]-\}}d�|d��|d�fVqdS(s%s=>%sR&R;N((t.0tktv(Rm(sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pys	<genexpr>�s(tjointitems(tval((RmsV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyR*�s	
(RR(+treR.RtRRRtsqlRtsqlfuncRt__all__t_PRECEDENCEtjson_getitem_optidx_precedencet	custom_opRMR RRRRRRIRJt
TypeEngineRtGenericFunctionRR$R+R-R0R2R4R5tcompiletVERBOSER_RdR\RAR*(((sV/opt/alt/python27/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/hstore.pyt<module>sn						%�
		*