+
    i                         R t ^ RIt^ RIHtHt ^ RIHtHtHt ^rt^t	Rt
Rt ! R R4      tRR ltRR	 ltRR
 ltRR ltRR ltR# )zImplementation of the JSON adaptation objects

This module exists to avoid a circular import problem: pyscopg2.extras depends
on psycopg2.extension, so I can't create the default JSON typecasters in
extensions importing register_json from extras.
N)	ISQLQuoteQuotedString)new_typenew_array_typeregister_typei  i  c                   L   a  ] tR t^.t o RtR
R ltR tR tR tR t	R t
R	tV tR# )Jsonz
An `~psycopg2.extensions.ISQLQuote` wrapper to adapt a Python object to
:sql:`json` data type.

`!Json` can be used to wrap any object supported by the provided *dumps*
function. If none is provided, the standard :py:func:`json.dumps()` is
used.

Nc                ^    Wn         R V n        T;'       g    \        P                  V n        R # N)adapted_connjsondumps_dumps)selfr   r   s   &&&hC:\Users\petid\OneDrive\Desktop\Maestro\MAESTRO\maestro-backend\venv\Lib\site-packages\psycopg2/_json.py__init__Json.__init__8   s!    
))tzz    c                    V\         J d   V # R # r
   )r   )r   protos   &&r   __conform__Json.__conform__=   s    IK r   c                $    V P                  V4      # )zSerialize *obj* in JSON format.

The default is to call `!json.dumps()` or the *dumps* function
provided in the constructor. You can override this method to create a
customized JSON wrapper.
)r   )r   objs   &&r   r   
Json.dumpsA   s     {{3r   c                    Wn         R # r
   )r   )r   conns   &&r   prepareJson.prepareJ   s    
r   c                    V P                  V P                  4      p\        V4      pV P                  e   VP	                  V P                  4       VP                  4       # r
   )r   r   r   r   r   	getquoted)r   sqss   &  r   r!   Json.getquotedM   sC    JJt||$!_::!JJtzz"||~r   c                B    V P                  4       P                  R R4      # )asciireplace)r!   decode)r   s   &r   __str__Json.__str__T   s    ~~&&w	::r   )r   r   r   r
   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r!   r)   __static_attributes____classdictcell__)__classdict__s   @r   r   r   .   s-     *
 ; ;r   r   c                    Vf   \        W4      w  r4\        W4W%P                  4       R7      w  rg\        Ya'       * ;'       d    T ;'       g    R4       Ve%   \        Yq'       * ;'       d    T ;'       g    R4       Wg3# )a  Create and register typecasters converting :sql:`json` type to Python objects.

:param conn_or_curs: a connection or cursor used to find the :sql:`json`
    and :sql:`json[]` oids; the typecasters are registered in a scope
    limited to this object, unless *globally* is set to `!True`. It can be
    `!None` if the oids are provided
:param globally: if `!False` register the typecasters only on
    *conn_or_curs*, otherwise register them globally
:param loads: the function used to parse the data into a Python object. If
    `!None` use `!json.loads()`, where `!json` is the module chosen
    according to the Python version (see above)
:param oid: the OID of the :sql:`json` type if known; If not, it will be
    queried on *conn_or_curs*
:param array_oid: the OID of the :sql:`json[]` array type if known;
    if not, it will be queried on *conn_or_curs*
:param name: the name of the data type to look for in *conn_or_curs*

The connection or cursor passed to the function will be used to query the
database and look for the OID of the :sql:`json` type (or an alternative
type if *name* if provided). No query is performed if *oid* and *array_oid*
are provided.  Raise `~psycopg2.ProgrammingError` if the type is not found.

N)loadsname)_get_json_oids_create_json_typecastersupperr   )conn_or_cursgloballyr4   oid	array_oidr5   JSON	JSONARRAYs   &&&&&&  r   register_jsonr?   Y   sp    2 {';.e**,8OD $55==>i!>!>,!F!F$G?r   c                0    \        WV\        \        R7      # )ac  
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following.

Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known
and fixed. This function allows specifying a customized *loads* function
for the default :sql:`json` type without querying the database.
All the parameters have the same meaning of `register_json()`.
)r9   r:   r4   r;   r<   )r?   JSON_OIDJSONARRAY_OIDr9   r:   r4   s   &&&r   register_default_jsonrD      s     l]< <r   c           	     2    \        WV\        \        RR7      # )aF  
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.

As in `register_default_json()`, the function allows to register a
customized *loads* function for the :sql:`jsonb` type at its known oid for
PostgreSQL 9.4 and following versions.  All the parameters have the same
meaning of `register_json()`.
jsonb)r9   r:   r4   r;   r<   r5   )r?   	JSONB_OIDJSONBARRAY_OIDrC   s   &&&r   register_default_jsonbrI      s     ln7L Lr   c                   a Sf   \         P                  oV3R lp\        V 3W44      pVe   \        V3V R2V4      pWV3# RpWV3# )z&Create typecasters for json data type.Nc                     < V f   R # S! V 4      # r
    )r"   curr4   s   &&r   typecast_json/_create_json_typecasters.<locals>.typecast_json   s    9Qxr   ARRAY)r   r4   r   r   )r;   r<   r4   r5   rN   r=   r>   s   &&f&   r   r7   r7      s[    }


 SGT1D"I=TF%.$G	 ? 	?r   c                    ^ RI Hp ^ RIHp V! V 4      w  rEVP                  pVP
                  P                  R8  ;'       d    R;'       g    RpVP                  RV,          V34       VP                  4       pWb8w  d#   VP                  '       g   VP                  4        V'       g   VP                  V R24      hV# )    )STATUS_IN_TRANSACTION)_solve_conn_cursi9 typarrayNULLz6SELECT t.oid, %s FROM pg_type t WHERE t.typname = %%s;z data type not found)psycopg2.extensionsrS   psycopg2.extrasrT   statusinfoserver_versionexecutefetchone
autocommitrollbackProgrammingError)	r9   r5   rS   rT   r   cursconn_statusrU   rs	   &&       r   r6   r6      s    90!,/JD ++K yy''50??ZII6H 	LL@
	G 	A +DOOO##tf,@$ABBHr   )NFNNNr   )NFN)Nr=   )r   )r/   r   psycopg2._psycopgr   r   r   r   r   rA   rB   rG   rH   r   r?   rD   rI   r7   r6   rL   r   r   <module>re      sV   <  5 E E  	(; (;V$N
<
L&r   