Ë
    ­Œj*2  ã                  óä  — 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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r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jN                  jP                  «      Z( G d!„ d"e(«      Z) G d#„ d$ejN                  «      Z' G d%„ d&e'«      Z*y')(é    )Úannotations)ÚAny)ÚCallable)ÚList)ÚOptional)ÚTYPE_CHECKING)ÚUnioné   )ÚARRAY)Úarray)ÚASTEXT)ÚCONTAINED_BY)ÚCONTAINS)ÚDELETE_PATH)ÚHAS_ALL)ÚHAS_ANY)ÚHAS_KEY)ÚJSONPATH_ASTEXT)ÚPATH_EXISTS)Ú
PATH_MATCHé   )Útypes)Úcast)Ú_T)ÚDialect)ÚColumnElement)Ú_BindProcessorType)Ú_LiteralProcessorType)Ú
TypeEngine)ÚJSONÚJSONBc                  ó8   — e Zd Z	 	 	 	 	 	 dd„Zdd„Z	 	 	 	 dd„Zy)ÚJSONPathTypec                ó   ‡— dˆfd„}|S )Nc                óŽ   •— t        | t        «      r| S | r#ddj                  t        t        | «      «      z  } nd} ‰r ‰| «      } | S )Nz{%s}z, z{})Ú
isinstanceÚstrÚjoinÚmap)ÚvalueÚ
super_procs    €úm/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/sqlalchemy/dialects/postgresql/json.pyÚprocessz(JSONPathType._processor.<locals>.process/   sI   ø€ Ü˜%¤Ô%ð �Ùð  $§)¡)¬C´°U«OÓ"<Ñ=‘à�ÙÙ" 5Ó)�ØˆLó    )r*   r   Úreturnr   © )ÚselfÚdialectr+   r-   s     ` r,   Ú
_processorzJSONPathType._processor,   s   ø€ õ	ð ˆr.   c                óD   — | j                  || j                  |«      «      S ©N)r3   Ústring_bind_processor©r1   r2   s     r,   Úbind_processorzJSONPathType.bind_processor@   s   € Ø�‰˜w¨×(BÑ(BÀ7Ó(KÓLÐLr.   c                óD   — | j                  || j                  |«      «      S r5   )r3   Ústring_literal_processorr7   s     r,   Úliteral_processorzJSONPathType.literal_processorC   s    € ð �‰˜w¨×(EÑ(EÀgÓ(NÓOÐOr.   N)r2   r   r+   zOptional[Callable[[Any], Any]]r/   zCallable[[Any], Any])r2   r   r/   z_BindProcessorType[Any])r2   r   r/   z_LiteralProcessorType[Any])Ú__name__Ú
__module__Ú__qualname__r3   r8   r;   r0   r.   r,   r#   r#   +   s=   „ ðØðØ,Jðà	óó(MðPØðPà	#ôPr.   r#   c                  ó   — e Zd ZdZd Zy)Ú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__r0   r.   r,   r@   r@   I   s   „ ñð  �Nr.   r@   c                  óª   ‡ — e Zd ZU dZdZ ej                  «       Zded<   	 	 d	 	 	 d	ˆ fd„Z	 G d„ dej                  j                  e   «      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`

    TzTypeEngine[str]Úastext_typec                ó:   •— t         ‰| �  |¬«       |�|| _        yy)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__rD   )r1   rF   rD   Ú	__class__s      €r,   rH   zJSON.__init__¬   s(   ø€ ô2 	‰Ñ lÐÔ3ØÐ"Ø*ˆDÕð #r.   c                  ó.   — e Zd ZU dZded<   edd„«       Zy)úJSON.Comparatorú6Define comparison operations for :class:`_types.JSON`.r    Útypec                óÖ  — t        | j                  j                  j                  t        j
                  j                  «      rT| j                  j                  j                  t        | j                  j                  | j                  j                  ¬«      S | j                  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ÚrightrM   Úsqltypesr    r#   ÚleftÚoperater   rD   r   )r1   s    r,   ÚastextzJSON.Comparator.astextÎ   sœ   € ô ˜$Ÿ)™)Ÿ/™/×.Ñ.´·±×0JÑ0JÔKØ—y‘y—~‘~×-Ñ-Ü#Ø—I‘I—O‘OØ $§	¡	× 5Ñ 5ð .ó ð ð —y‘y—~‘~×-Ñ-Ü˜DŸI™IŸO™O¸¿¹×9NÑ9Nð .ó ð r.   N)r/   zColumnElement[str])r<   r=   r>   rA   Ú__annotations__ÚpropertyrV   r0   r.   r,   Ú
ComparatorrK   É   s   … ÙDà‹
à	ò	ó 
ñ	r.   rY   )FN)rF   ÚboolrD   zOptional[TypeEngine[str]])r<   r=   r>   rA   Úrender_bind_castrS   ÚTextrD   rW   rH   r    rY   r   Úcomparator_factoryÚ__classcell__)rI   s   @r,   r    r    [   sf   ø… ñKðZ ÐØ#0 8§=¡=£?€K�Ó2ð #Ø15ð+àð+ð /õ+ô:�X—]‘]×-Ñ-¨bÑ1ô ð< $Ôr.   r    c                  óH   — e Zd ZdZd Z G d„ dej                  e   «      ZeZy)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                  ód   — e Zd ZU dZded<   dd„Zdd„Zdd„Zdd„Zdd„Z		 	 	 	 dd	„Z
dd
„Zdd„Zy)úJSONB.ComparatorrL   r!   rM   c                óN   — | j                  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.
            rO   )rU   r   rS   ÚBoolean©r1   Úothers     r,   Úhas_keyzJSONB.Comparator.has_key#  ó   € ð —<‘<¤¨¼H×<LÑ<L�<ÓMÐMr.   c                óN   — | j                  t        |t        j                  ¬«      S )zxBoolean expression.  Test for presence of all keys in jsonb
            (equivalent of the ``?&`` operator)
            rO   )rU   r   rS   rc   rd   s     r,   Úhas_allzJSONB.Comparator.has_all)  rg   r.   c                óN   — | j                  t        |t        j                  ¬«      S )zwBoolean expression.  Test for presence of any key in jsonb
            (equivalent of the ``?|`` operator)
            rO   )rU   r   rS   rc   rd   s     r,   Úhas_anyzJSONB.Comparator.has_any/  rg   r.   c                óN   — | j                  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.
            rO   )rU   r   rS   rc   )r1   re   Úkwargss      r,   ÚcontainszJSONB.Comparator.contains5  s   € ð —<‘<¤¨%¼X×=MÑ=M�<ÓNÐNr.   c                óN   — | j                  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).
            rO   )rU   r   rS   rc   rd   s     r,   Úcontained_byzJSONB.Comparator.contained_by?  s'   € ð
 —<‘<Ü˜e´×1AÑ1Að  ó ð r.   c                ó¶   — t        |t        «      st        |«      }t        |t        t        j
                  «      «      }| 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
            rO   )	r&   Ú	_pg_arrayr   r   rS   ÚTEXTrU   r   r!   )r1   r   Ú
right_sides      r,   Údelete_pathzJSONB.Comparator.delete_pathH  sB   € ô ˜e¤YÔ/Ü! %Ó(�Ü˜e¤U¬8¯=©=Ó%9Ó:ˆJØ—<‘<¤¨ZÄU�<ÓKÐKr.   c                óN   — | j                  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
            rO   )rU   r   rS   rc   rd   s     r,   Úpath_existszJSONB.Comparator.path_existsX  s'   € ð —<‘<Ü˜U´×0@Ñ0@ð  ó ð r.   c                óN   — | j                  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
            rO   )rU   r   rS   rc   rd   s     r,   Ú
path_matchzJSONB.Comparator.path_matchb  s'   € ð —<‘<Ü˜E¬x×/?Ñ/?ð  ó ð r.   N)re   r   r/   úColumnElement[bool])re   r   rm   r   r/   rz   )r   z Union[List[str], _pg_array[str]]r/   zColumnElement[JSONB])r<   r=   r>   rA   rW   rf   ri   rk   rn   rp   ru   rw   ry   r0   r.   r,   rY   ra     sI   … ÙDà‹ó	Nó	Nó	Nó	Oó	ð	LØ9ð	Là!ó	Ló 	ô	r.   rY   N)	r<   r=   r>   rA   rB   r    rY   r   r]   r0   r.   r,   r!   r!   ê   s/   „ ñ/ðb €NôO�T—_‘_ RÑ(ô Oðb $Ñr.   r!   N)+Ú
__future__r   Útypingr   r   r   r   r   r	   r   r   rr   Ú	operatorsr   r   r   r   r   r   r   r   r   r   Ú r   rS   Úsqlr   Úsql._typingr   Úengine.interfacesr   Úsql.elementsr   Úsql.type_apir   r   r   Ú__all__r    r#   r@   r!   r0   r.   r,   Ú<module>r…      s¥   ðõ #å Ý Ý Ý Ý  Ý å Ý %Ý Ý #Ý Ý "Ý Ý Ý Ý &Ý "Ý !Ý !Ý Ý áÝ,Ý-Ý2Ý5Ý*à
€ôP�8—=‘=×-Ñ-ô Pô< ˆ|ô  ô$L$ˆ8�=‰=ô L$ô^E$ˆDõ E$r.   