Ë
    r™ãjJ  ã                  ód  — 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  ede¬«      Z G d„ dej(                  e   «      Z G d„ d«      Z G d„ deej(                  j,                  «      Z G d„ deej(                  j.                  «      Zy)é    )Úannotations)ÚAny)ÚTYPE_CHECKING)ÚTypeVaré   )Útypes)Ú_NoArg)ÚNO_ARG)Ú_T_JSON)ÚDialect)Ú_BindProcessorType)Ú_LiteralProcessorTypeÚ_T)Úboundc                  ó<   ‡ — e Zd ZU dZded<   def	 	 	 dˆ fd„Zˆ xZS )ÚJSONaÂ
  Oracle JSON type.

    .. versionadded:: 2.1

    Oracle Database supports JSON storage and querying for character and BLOB
    datatypes in Oracle 12c, and supports a dedicated JSON data type as of
    Oracle 21c. SQLAlchemy supports both of these scenarios when using the
    oracledb DBAPI.  This type is used implicitly whenever the base
    :class:`_types.JSON` datatype is used against an Oracle backend, or may be
    constructed directly for access to Oracle-specific parameters such as
    :paramref:`_oracle.JSON.use_blob`.

    Index operations are adapted to render using the ``JSON_QUERY`` and
    ``JSON_VALUE`` functions at the database level.

    **Platform Support** - When using Oracle Database versions prior to 21c,
    BLOB is used as the storage format.  In 21c or later, the native JSON
    datatype is used.  This can be overridden using the
    :paramref:`_oracle.JSON.use_blob` parameter.

    **Serialization / Deserialization** - JSON serialization of bound
    parameters uses Python ``json.dumps()`` by default rather than oracledb's
    native serializer, in order to support the
    :paramref:`_sqltypes.JSON.none_as_null` feature.  The default serializer
    does **not** accept Python ``Decimal`` objects; to use a custom serializer,
    pass :paramref:`_sa.create_engine.json_serializer` to
    :func:`_sa.create_engine`.

    When using the native JSON datatype (21c+), deserialization uses oracledb's
    native deserializer by default, which is required for JSON values larger
    than 32767 bytes.  However, this deserializer returns all numeric values as
    ``Decimal`` since Oracle Database stores JSON numbers using its internal
    NUMBER type.  To receive standard Python numeric types, pass
    ``json_deserializer=json.loads`` via
    :paramref:`_sa.create_engine.json_deserializer`; note that this limits
    maximum JSON value size to 32767 bytes.  When using BLOB storage,
    SQLAlchemy deserializes using ``json.loads()`` directly rather than the
    oracledb deserializer.

    **CHECK Constraint with BLOB** - When using BLOB storage, either on Oracle
    Database versions prior to 21c or via the :paramref:`_oracle.JSON.use_blob`
    parameter, the oracledb driver documentation recommends adding a
    ``<colname> IS JSON`` check constraint to indicate to the driver that the
    column stores JSON data.  This constraint is **not** automatically
    generated by :class:`_oracle.JSON` and is not required by SQLAlchemy's
    implementation in order to read JSON data from the column. If desired, it
    can be added explicitly using :class:`_schema.CheckConstraint`.

    .. seealso::

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

    úbool | _NoArgÚuse_blobFc                ó4   •— t         ‰| �  |¬«       || _        y)aô  Construct a :class:`_oracle.JSON` type.

        :param none_as_null=False: if True, persist the value ``None`` as a SQL
         NULL value, not the JSON encoding of ``null``.  See the notes at
         :paramref:`_sqltypes.JSON.none_as_null` for complete background on
         this option.

        :param use_blob: A boolean parameter indicating if the type should be
         rendered in DDL using BLOB instead of JSON.   Normally, JSON or BLOB
         is chosen automatically based on the version of Oracle in use
         (21c or greater for JSON).   If the parameter is left at its default
         value of the ``NO_ARG`` constant, this automatic selection is used.
         However when ``True``, the BLOB datatype will be used unconditionally,
         and if ``False``, JSON will be used unconditionally (including on
         backends older than 21c, which will raise an error by the server.
         This may be used to assert that only JSON-supporting backends
         should be used).

        )Únone_as_nullN)ÚsuperÚ__init__r   )Úselfr   r   Ú	__class__s      €új/var/www/html/python-recuperauto-other/env/lib/python3.12/site-packages/sqlalchemy/dialects/oracle/json.pyr   zJSON.__init__V   s   ø€ ô. 	‰Ñ lÐÔ3Ø ˆ�ó    )r   Úboolr   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r
   r   Ú__classcell__)r   s   @r   r   r      s2   ø… ñ5ðn Óð $)ÀFð!Ø ð!Ø4A÷!ñ !r   r   c                  ó,   — e Zd Zdd„Zdd„Z	 	 	 	 dd„Zy)Ú_FormatTypeMixinc                ó   — t        «       ‚©N)ÚNotImplementedError©r   Úvalues     r   Ú_format_valuez_FormatTypeMixin._format_valuer   s   € Ü!Ó#Ð#r   c                ó:   ‡ ‡— ‰ j                  |«      Šdˆ ˆfd„}|S )Nc                ó>   •— ‰j                  | «      } ‰r ‰| «      } | S r'   ©r+   ©r*   r   Ú
super_procs    €€r   Úprocessz0_FormatTypeMixin.bind_processor.<locals>.processx   ó%   ø€ Ø×&Ñ& uÓ-ˆEÙÙ" 5Ó)�ØˆLr   )r*   r   Úreturnr   )Ústring_bind_processor©r   Údialectr1   r0   s   `  @r   Úbind_processorz_FormatTypeMixin.bind_processoru   s   ù€ Ø×/Ñ/°Ó8ˆ
ö	ð ˆr   c                ó:   ‡ ‡— ‰ j                  |«      Šdˆ ˆfd„}|S )Nc                ó>   •— ‰j                  | «      } ‰r ‰| «      } | S r'   r.   r/   s    €€r   r1   z3_FormatTypeMixin.literal_processor.<locals>.process…   r2   r   ©r*   r   r3   Ústr)Ústring_literal_processorr5   s   `  @r   Úliteral_processorz"_FormatTypeMixin.literal_processor€   s!   ù€ ð ×2Ñ2°7Ó;ˆ
ö	ð ˆr   Nr:   )r6   r   r3   z_BindProcessorType[Any])r6   r   r3   z_LiteralProcessorType[Any])r   r   r    r+   r7   r=   © r   r   r%   r%   q   s!   „ ó$ó	ðØðà	#ôr   r%   c                  ó   — e Zd Zdd„Zy)ÚJSONIndexTypec                ó:   — t        |t        «      rd|› d�S d|› d�S )Nz$[ú]z$."ú"©Ú
isinstanceÚintr)   s     r   r+   zJSONIndexType._format_value�   s(   € Ü�eœSÔ!Ø˜�w˜a�=Ð à˜˜˜q�>Ð!r   Nr:   ©r   r   r    r+   r>   r   r   r@   r@   Ž   s   „ ô"r   r@   c                  ó   — e Zd Zdd„Zy)ÚJSONPathTypec                ó8   — ddj                  d„ |D «       «      z  S )Nz$%sÚ c              3  óT   K  — | ]   }t        |t        «      rd |› d�nd|› d�–— Œ" y­w)ú[rB   z."rC   NrD   )Ú.0Úelems     r   ú	<genexpr>z-JSONPathType._format_value.<locals>.<genexpr>™   s6   è ø€ ò àô  *¨$´Ô4�!�D�6˜‘¸B¸t¸fÀA¸,ÓFñùs   ‚&()Újoinr)   s     r   r+   zJSONPathType._format_value—   s(   € ØØ�G‰Gñ à!ôó ñ
ð 	
r   Nr:   rG   r>   r   r   rI   rI   –   s   „ ô
r   rI   N)Ú
__future__r   Útypingr   r   r   rK   r   ÚsqltypesÚsql.baser	   r
   Úsql.sqltypesr   Úengine.interfacesr   Úsql.type_apir   r   r   r   r%   r@   rI   r>   r   r   ú<module>rY      s‹   ðõ #å Ý  Ý å !Ý Ý Ý #áÝ,Ý2Ý5áˆT˜Ô€ôR!ˆ8�=‰=˜Ñ!ô R!÷jñ ô:"Ð$ h§m¡m×&AÑ&Aô "ô
Ð# X§]¡]×%?Ñ%?õ 
r   