§
    WøÁib-  ã                   ó@  — 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 d dlmZ ddlmZ ddlmZ dZ G d„ dej        j        ¦  «        Z G d„ de¦  «        Z G d„ dej        ¦  «        Z G d„ de¦  «        ZdS )é   )ÚARRAY)Úarray)ÚASTEXT)ÚCONTAINED_BY)ÚCONTAINS)ÚDELETE_PATH)ÚHAS_ALL)ÚHAS_ANY)ÚHAS_KEY)ÚJSONPATH_ASTEXT)ÚPATH_EXISTS)Ú
PATH_MATCHé   )Útypes)Úcast)ÚJSONÚJSONBc                   ó    — e Zd Zd„ Zd„ Zd„ ZdS )ÚJSONPathTypec                 ó   ‡— ˆfd„}|S )Nc                 ó°   •— t          | t          ¦  «        r| S | r,dd                     t          t          | ¦  «        ¦  «        z  } nd} ‰r ‰| ¦  «        } | S )Nz{%s}z, z{})Ú
isinstanceÚstrÚjoinÚmap)ÚvalueÚ
super_procs    €úm/var/www/html/jarvis.com/web/backend/venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/json.pyÚprocessz(JSONPathType._processor.<locals>.process   sg   ø€ Ý˜%¥Ñ%Ô%ð 	ð �Øð ð  $§)¢)­Cµ°U©O¬OÑ"<Ô"<Ñ=��à�Øð *Ø"˜
 5Ñ)Ô)�ØˆLó    © )ÚselfÚdialectr   r   s     ` r   Ú
_processorzJSONPathType._processor   s#   ø€ ð	ð 	ð 	ð 	ð 	ð ˆr    c                 óT   — |                       ||                      |¦  «        ¦  «        S ©N)r$   Ústring_bind_processor©r"   r#   s     r   Úbind_processorzJSONPathType.bind_processor/   s$   € Ø�Š˜w¨×(BÒ(BÀ7Ñ(KÔ(KÑLÔLÐLr    c                 óT   — |                       ||                      |¦  «        ¦  «        S r&   )r$   Ústring_literal_processorr(   s     r   Úliteral_processorzJSONPathType.literal_processor2   s$   € Ø�Š˜w¨×(EÒ(EÀgÑ(NÔ(NÑOÔOÐOr    N)Ú__name__Ú
__module__Ú__qualname__r$   r)   r,   r!   r    r   r   r      sI   € € € € € ðð ð ð$Mð Mð MðPð Pð Pð Pð Pr    r   c                   ó   — e Zd ZdZd ZdS )ÚJSONPATHad  JSON Path Type.

    This is usually required to cast literal values to json path when using
    json search like function, such as ``jsonb_path_query_array`` or
    ``jsonb_path_exists``::

        stmt = sa.select(
            sa.func.jsonb_path_query_array(
                table.c.jsonb_col, cast("$.address.id", JSONPATH)
            )
        )

    N)r-   r.   r/   Ú__doc__Ú__visit_name__r!   r    r   r1   r1   6   s   € € € € € ðð ð  €N€N€Nr    r1   c                   óz   ‡ — e Zd ZdZdZ ej        ¦   «         Zdˆ fd„	Z G d„ dej	        j
        ¦  «        Z
e
Zˆ xZS )	r   a
  Represent the PostgreSQL JSON type.

    :class:`_postgresql.JSON` is used automatically whenever the base
    :class:`_types.JSON` datatype is used against a PostgreSQL backend,
    however base :class:`_types.JSON` datatype does not provide Python
    accessors for PostgreSQL-specific comparison methods such as
    :meth:`_postgresql.JSON.Comparator.astext`; additionally, to use
    PostgreSQL ``JSONB``, the :class:`_postgresql.JSONB` datatype should
    be used explicitly.

    .. seealso::

        :class:`_types.JSON` - main documentation for the generic
        cross-platform JSON datatype.

    The operators provided by the PostgreSQL version of :class:`_types.JSON`
    include:

    * Index operations (the ``->`` operator)::

        data_table.c.data['some key']

        data_table.c.data[5]


    * Index operations returning text (the ``->>`` operator)::

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

      Note that equivalent functionality is available via the
      :attr:`.JSON.Comparator.as_string` accessor.

    * Index operations with CAST
      (equivalent to ``CAST(col ->> ['some key'] AS <type>)``)::

        data_table.c.data['some key'].astext.cast(Integer) == 5

      Note that equivalent functionality is available via the
      :attr:`.JSON.Comparator.as_integer` and similar accessors.

    * Path index operations (the ``#>`` operator)::

        data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')]

    * Path index operations returning text (the ``#>>`` operator)::

        data_table.c.data[('key_1', 'key_2', 5, ..., 'key_n')].astext == 'some value'

    Index operations return an expression object whose type defaults to
    :class:`_types.JSON` by default,
    so that further JSON-oriented instructions
    may be called upon the result type.

    Custom serializers and deserializers are specified at the dialect level,
    that is using :func:`_sa.create_engine`.  The reason for this is that when
    using psycopg2, the DBAPI only allows serializers at the per-cursor
    or per-connection level.   E.g.::

        engine = create_engine("postgresql+psycopg2://scott:tiger@localhost/test",
                                json_serializer=my_serialize_fn,
                                json_deserializer=my_deserialize_fn
                        )

    When using the psycopg2 dialect, the json_deserializer is registered
    against the database using ``psycopg2.extras.register_default_json``.

    .. seealso::

        :class:`_types.JSON` - Core level JSON type

        :class:`_postgresql.JSONB`

    TFNc                 ób   •— t          ¦   «                              |¬¦  «         |�	|| _        dS dS )a�  Construct a :class:`_types.JSON` type.

        :param none_as_null: if True, persist the value ``None`` as a
         SQL NULL value, not the JSON encoding of ``null``.   Note that
         when this flag is False, the :func:`.null` construct can still
         be used to persist a NULL value::

             from sqlalchemy import null
             conn.execute(table.insert(), {"data": null()})

         .. seealso::

              :attr:`_types.JSON.NULL`

        :param astext_type: the type to use for the
         :attr:`.JSON.Comparator.astext`
         accessor on indexed attributes.  Defaults to :class:`_types.Text`.

        )Únone_as_nullN)ÚsuperÚ__init__Úastext_type)r"   r6   r9   Ú	__class__s      €r   r8   zJSON.__init__–   s<   ø€ õ( 	‰Œ×Ò lÐÑ3Ô3Ð3ØÐ"Ø*ˆDÔÐÐð #Ð"r    c                   ó(   — e Zd ZdZed„ ¦   «         ZdS )úJSON.Comparatorú6Define comparison operations for :class:`_types.JSON`.c                 óJ  — t          | j        j        j        t          j        j        ¦  «        r;| j        j                             t          | j        j        | j        j
        ¬¦  «        S | j        j                             t          | j        j        | j        j
        ¬¦  «        S )a  On an indexed expression, use the "astext" (e.g. "->>")
            conversion when rendered in SQL.

            E.g.::

                select(data_table.c.data['some key'].astext)

            .. seealso::

                :meth:`_expression.ColumnElement.cast`

            ©Úresult_type)r   ÚexprÚrightÚtypeÚsqltypesr   r   ÚleftÚoperater   r9   r   )r"   s    r   ÚastextzJSON.Comparator.astext±   sˆ   € õ ˜$œ)œ/Ô.µ´Ô0JÑKÔKð 	Ø”y”~×-Ò-Ý#Ø”I”OØ $¤	Ô 5ð .ñ ô ð ð ”y”~×-Ò-Ý˜DœIœO¸¼Ô9Nð .ñ ô ð r    N)r-   r.   r/   r2   ÚpropertyrG   r!   r    r   Ú
Comparatorr<   ®   s3   € € € € € ØDÐDà	ð	ð 	ñ 
Œð	ð 	ð 	r    rI   )FN)r-   r.   r/   r2   Úrender_bind_castrD   ÚTextr9   r8   r   rI   Úcomparator_factoryÚ__classcell__)r:   s   @r   r   r   H   sŽ   ø€ € € € € ðHð HðT ÐØ�(”-‘/”/€Kð+ð +ð +ð +ð +ð +ð0ð ð ð ð �X”]Ô-ñ ô ð ð8 $ÐÐÐÐÐr    r   c                   ó@   — e Zd ZdZd Z G d„ dej        ¦  «        ZeZdS )r   a  Represent the PostgreSQL JSONB type.

    The :class:`_postgresql.JSONB` type stores arbitrary JSONB format data,
    e.g.::

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

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

    The :class:`_postgresql.JSONB` type includes all operations provided by
    :class:`_types.JSON`, including the same behaviors for indexing
    operations.
    It also adds additional operators specific to JSONB, including
    :meth:`.JSONB.Comparator.has_key`, :meth:`.JSONB.Comparator.has_all`,
    :meth:`.JSONB.Comparator.has_any`, :meth:`.JSONB.Comparator.contains`,
    :meth:`.JSONB.Comparator.contained_by`,
    :meth:`.JSONB.Comparator.delete_path`,
    :meth:`.JSONB.Comparator.path_exists` and
    :meth:`.JSONB.Comparator.path_match`.

    Like the :class:`_types.JSON` type, the :class:`_postgresql.JSONB`
    type does not detect
    in-place changes when used with the ORM, unless the
    :mod:`sqlalchemy.ext.mutable` extension is used.

    Custom serializers and deserializers
    are shared with the :class:`_types.JSON` class,
    using the ``json_serializer``
    and ``json_deserializer`` keyword arguments.  These must be specified
    at the dialect level using :func:`_sa.create_engine`.  When using
    psycopg2, the serializers are associated with the jsonb type using
    ``psycopg2.extras.register_default_jsonb`` on a per-connection basis,
    in the same way that ``psycopg2.extras.register_default_json`` is used
    to register these handlers with the json type.

    .. seealso::

        :class:`_types.JSON`

    c                   óB   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
S )úJSONB.Comparatorr=   c                 óP   — |                       t          |t          j        ¬¦  «        S )z™Boolean expression.  Test for presence of a key (equivalent of
            the ``?`` operator).  Note that the key may be a SQLA expression.
            r?   )rF   r   rD   ÚBoolean©r"   Úothers     r   Úhas_keyzJSONB.Comparator.has_key  ó   € ð —<’<¥¨½HÔ<L�<ÑMÔMÐMr    c                 óP   — |                       t          |t          j        ¬¦  «        S )zxBoolean expression.  Test for presence of all keys in jsonb
            (equivalent of the ``?&`` operator)
            r?   )rF   r	   rD   rR   rS   s     r   Úhas_allzJSONB.Comparator.has_all	  rV   r    c                 óP   — |                       t          |t          j        ¬¦  «        S )zwBoolean expression.  Test for presence of any key in jsonb
            (equivalent of the ``?|`` operator)
            r?   )rF   r
   rD   rR   rS   s     r   Úhas_anyzJSONB.Comparator.has_any  rV   r    c                 óP   — |                       t          |t          j        ¬¦  «        S )a"  Boolean expression.  Test if keys (or array) are a superset
            of/contained the keys of the argument jsonb expression
            (equivalent of the ``@>`` operator).

            kwargs may be ignored by this operator but are required for API
            conformance.
            r?   )rF   r   rD   rR   )r"   rT   Úkwargss      r   ÚcontainszJSONB.Comparator.contains  s   € ð —<’<¥¨%½XÔ=M�<ÑNÔNÐNr    c                 óP   — |                       t          |t          j        ¬¦  «        S )z¬Boolean expression.  Test if keys are a proper subset of the
            keys of the argument jsonb expression
            (equivalent of the ``<@`` operator).
            r?   )rF   r   rD   rR   rS   s     r   Úcontained_byzJSONB.Comparator.contained_by  s)   € ð
 —<’<Ý˜eµÔ1Að  ñ ô ð r    c                 óÜ   — t          |t          ¦  «        st          |¦  «        }t          |t          t          j        ¦  «        ¦  «        }|                      t          |t          ¬¦  «        S )a=  JSONB expression. Deletes field or array element specified in
            the argument array (equivalent of the ``#-`` operator).

            The input may be a list of strings that will be coerced to an
            ``ARRAY`` or an instance of :meth:`_postgres.array`.

            .. versionadded:: 2.0
            r?   )	r   Ú	_pg_arrayr   r   rD   ÚTEXTrF   r   r   )r"   r   Ú
right_sides      r   Údelete_pathzJSONB.Comparator.delete_path(  sT   € õ ˜e¥YÑ/Ô/ð )Ý! %Ñ(Ô(�Ý˜e¥U­8¬=Ñ%9Ô%9Ñ:Ô:ˆJØ—<’<¥¨ZÅU�<ÑKÔKÐKr    c                 óP   — |                       t          |t          j        ¬¦  «        S )z¸Boolean expression. Test for presence of item given by the
            argument JSONPath expression (equivalent of the ``@?`` operator).

            .. versionadded:: 2.0
            r?   )rF   r   rD   rR   rS   s     r   Úpath_existszJSONB.Comparator.path_exists6  s)   € ð —<’<Ý˜UµÔ0@ð  ñ ô ð r    c                 óP   — |                       t          |t          j        ¬¦  «        S )a  Boolean expression. Test if JSONPath predicate given by the
            argument JSONPath expression matches
            (equivalent of the ``@@`` operator).

            Only the first item of the result is taken into account.

            .. versionadded:: 2.0
            r?   )rF   r   rD   rR   rS   s     r   Ú
path_matchzJSONB.Comparator.path_match@  s)   € ð —<’<Ý˜E­xÔ/?ð  ñ ô ð r    N)r-   r.   r/   r2   rU   rX   rZ   r]   r_   rd   rf   rh   r!   r    r   rI   rP      s¡   € € € € € ØDÐDð	Nð 	Nð 	Nð	Nð 	Nð 	Nð	Nð 	Nð 	Nð	Oð 	Oð 	Oð	ð 	ð 	ð	Lð 	Lð 	Lð	ð 	ð 	ð	ð 	ð 	ð 	ð 	r    rI   N)r-   r.   r/   r2   r3   r   rI   rL   r!   r    r   r   r   Í   s_   € € € € € ð.ð .ð` €NðKð Kð Kð Kð K�T”_ñ Kô Kð KðZ $ÐÐÐr    r   N)r   r   ra   Ú	operatorsr   r   r   r   r	   r
   r   r   r   r   Ú r   rD   Úsqlr   Ú__all__r   r   r1   r   r!   r    r   ú<module>rm      sÜ  ðð Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ø Ð Ð Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &Ø "Ð "Ð "Ð "Ð "Ð "Ø !Ð !Ð !Ð !Ð !Ð !Ø !Ð !Ð !Ð !Ð !Ð !Ø Ð Ð Ð Ð Ð à
€ðPð Pð Pð Pð P�8”=Ô-ñ Pô Pð Pð4 ð  ð  ð  ð  ˆ|ñ  ô  ð  ð$B$ð B$ð B$ð B$ð B$ˆ8Œ=ñ B$ô B$ð B$ðJ@$ð @$ð @$ð @$ð @$ˆDñ @$ô @$ð @$ð @$ð @$r    