
    -hB*                        S SK Jr  SSKJr  SSKJr  SSKJr  Sr\R                  \R                     r\R                  " S\SSS	9r\R                  " S
\SSS	9r\R                  " S\SSS	9r\R                  " S\SSS	9r\R                  " S\SSS	9r\R                  " S\SSS	9r\R                  " S\SSS	9r " S S\R(                  R*                  5      r " S S\R(                  5      r " S S\5      rg)    )absolute_import   )types)util)	operators)JSONJSONBz->>T)
precedencenatural_self_precedenteager_groupingz#>>?z?&z?|z@>z<@c                        \ rS rSrS rS rSrg)JSONPathTypeE   c                 6   ^ U R                  U5      mU4S jnU$ )Nc                    > [        U [        R                  R                  5      (       d   eU  Vs/ s H  n[        R                  " U5      PM     nnSSR                  U5      -  n T(       a  T" U 5      n U $ s  snf Nz{%s}z, 
isinstancer   collections_abcSequence	text_typejoinvalueelemtokens
super_procs      xC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/dialects/postgresql/json.pyprocess,JSONPathType.bind_processor.<locals>.processI   i    eT%9%9%B%BCCCC7<=utdnnT*uF=dii/0E"5)L	 >    A8)string_bind_processorselfdialectr    r   s      @r   bind_processorJSONPathType.bind_processorF   s    //8
	     c                 6   ^ U R                  U5      mU4S jnU$ )Nc                    > [        U [        R                  R                  5      (       d   eU  Vs/ s H  n[        R                  " U5      PM     nnSSR                  U5      -  n T(       a  T" U 5      n U $ s  snf r   r   r   s      r   r    /JSONPathType.literal_processor.<locals>.processV   r"   r#   )string_literal_processorr%   s      @r   literal_processorJSONPathType.literal_processorS   s    227;
	 r*    N)__name__
__module____qualname____firstlineno__r(   r/   __static_attributes__r1   r*   r   r   r   E   s    r*   r   c                      ^  \ rS rSrSr\R                  " 5       rSU 4S jjr " S S\R                  R                  5      r
\
rSrU =r$ )r   a   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'

.. versionchanged:: 1.1  The :meth:`_expression.ColumnElement.cast`
   operator on
   JSON objects now requires that the :attr:`.JSON.Comparator.astext`
   modifier be called explicitly, if the cast works only from a textual
   string.

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://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`

.. versionchanged:: 1.1 :class:`_postgresql.JSON` is now a PostgreSQL-
   specific specialization of the new :class:`_types.JSON` type.

c                 <   > [         [        U ]  US9  Ub  X l        gg)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())

 .. versionchanged:: 0.9.8 - Added ``none_as_null``, and :func:`.null`
    is now supported in order to persist a NULL value.

 .. 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`.

 .. versionadded:: 1.1

)none_as_nullN)superr   __init__astext_type)r&   r:   r=   	__class__s      r   r<   JSON.__init__   s(    2 	dD""="* #r*   c                   (    \ rS rSrSr\S 5       rSrg)JSON.Comparator   6Define comparison operations for :class:`_types.JSON`.c                    [        U R                  R                  R                  [        R
                  R                  5      (       aQ  U R                  R                  R                  [        U R                  R                  U R                  R                  S9$ U R                  R                  R                  [        U R                  R                  U R                  R                  S9$ )zOn 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operateJSONPATH_ASTEXTr=   ASTEXT)r&   s    r   astextJSON.Comparator.astext   s     $))//..0J0JKKyy~~--#IIOO $		 5 5 .   yy~~--DIIOO9N9N .  r*   r1   N)r2   r3   r4   r5   __doc__propertyrO   r6   r1   r*   r   
ComparatorrA      s    D		 
	r*   rS   )r=   )FN)r2   r3   r4   r5   rQ   rJ   Textr=   r<   r   rS   comparator_factoryr6   __classcell__)r>   s   @r   r   r   a   s:    Qf --/K+:X]]-- 8 $r*   r   c                   J    \ rS rSrSrS r " S S\R                  5      r\rSr	g)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`,
and :meth:`.JSONB.Comparator.contained_by`.

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.

.. versionadded:: 0.9.7

.. seealso::

    :class:`_types.JSON`

c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
JSONB.Comparatori%  rC   c                 H    U R                  [        U[        R                  S9$ )zBoolean expression.  Test for presence of a key (equivalent of
the ``?`` operator).  Note that the key may be a SQLA expression.
rE   )rL   HAS_KEYrJ   Booleanr&   others     r   has_keyJSONB.Comparator.has_key(       <<H<L<L<MMr*   c                 H    U R                  [        U[        R                  S9$ )z`Boolean expression.  Test for presence of all keys in jsonb
(equivalent of the ``?&`` operator)
rE   )rL   HAS_ALLrJ   r]   r^   s     r   has_allJSONB.Comparator.has_all.  rb   r*   c                 H    U R                  [        U[        R                  S9$ )z_Boolean expression.  Test for presence of any key in jsonb
(equivalent of the ``?|`` operator)
rE   )rL   HAS_ANYrJ   r]   r^   s     r   has_anyJSONB.Comparator.has_any4  rb   r*   c                 H    U R                  [        U[        R                  S9$ )zBoolean 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.
rE   )rL   CONTAINSrJ   r]   )r&   r_   kwargss      r   containsJSONB.Comparator.contains:  s     <<%X=M=M<NNr*   c                 H    U R                  [        U[        R                  S9$ )zBoolean expression.  Test if keys are a proper subset of the
keys of the argument jsonb expression
(equivalent of the ``<@`` operator).
rE   )rL   CONTAINED_BYrJ   r]   r^   s     r   contained_byJSONB.Comparator.contained_byD  s'    
 <<e1A1A    r*   r1   N)r2   r3   r4   r5   rQ   r`   re   ri   rn   rr   r6   r1   r*   r   rS   rZ   %  s"    D	N	N	N	O	r*   rS   r1   N)
r2   r3   r4   r5   rQ   __visit_name__r   rS   rU   r6   r1   r*   r   r	   r	      s(    -^ N&T__ &P $r*   r	   N)
__future__r    r   rJ   r   sqlr   __all___PRECEDENCEjson_getitem_opidx_precedence	custom_oprN   rM   r\   rd   rh   rl   rq   r   r   r	   r1   r*   r   <module>r}      s7   ' !   &&y'@'@A					
 %%		 

	 

	 

	 	 ""	8==-- 8O$8== O$dZ$D Z$r*   