o
    PDi5,                     @   s~   d dl mZ d dlZddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZ G dd	 d	ed
ZdS )    )UnionN   )	constants)BaseMetaClass)
DbTypeDB_TYPE_DATEDB_TYPE_TIMESTAMPDB_TYPE_TIMESTAMP_LTZDB_TYPE_TIMESTAMP_TZDB_TYPE_BINARY_FLOATDB_TYPE_BINARY_DOUBLEDB_TYPE_BINARY_INTEGERDB_TYPE_NUMBERDB_TYPE_VECTOR)DbObjectTypec                   @   s  e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Ze	dd Z
edeedf fddZedeedf fddZedeedf fddZedeedf fddZedeedf fddZedefddZedefddZedefddZedefd d!Zedeedf fd"d#Zedeedf fd$d%Zedeeef fd&d'Zedefd(d)Zedeedf fd*d+Z edee!j"df fd,d-Z#edeedf fd.d/Z$dS )0	FetchInfoz@
    Identifies metadata of columns that are being fetched.
    c                 C   s   t | |kS N)tuple)selfother r   L/var/www/Datamplify/venv/lib/python3.10/site-packages/oracledb/fetch_info.py__eq__:      zFetchInfo.__eq__c                 C   s   |dks|dkr| j S |dks|dkr| jS |dks|dkr!| jS |dks)|dkr,| jS |d	ks4|d
kr7| jS |dks?|dkrB| jS |dksJ|dkrM| jS t|trYt	| 
|S td)zG
        Return the parts mandated by the Python Database API.
        r   ir   i               zlist index out of range)name	type_codedisplay_sizeinternal_size	precisionscalenull_ok
isinstanceslicer   __getitem__
IndexError)r   indexr   r   r   r-   =   s"   
zFetchInfo.__getitem__c                 C   s   dS )z=
        Length mandated by the Python Database API.
           r   r   r   r   r   __len__S   s   zFetchInfo.__len__c                 C      t t| S r   )reprr   r1   r   r   r   __repr__Y   r   zFetchInfo.__repr__c                 C   r3   r   )strr   r1   r   r   r   __str__\   r   zFetchInfo.__str__c                 C   s   |  | }||_d |_|S r   )__new___impl_type)clsimplinfor   r   r   
_from_impl_   s   
zFetchInfo._from_implreturnNc                 C      | j jS )a  
        This read-only attribute returns a dictionary containing the
        `annotations <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=
        GUID-1AC16117-BBB6-4435-8794-2B99F8F68052>`__ associated with the
        fetched column. If there are no annotations, the value *None* is
        returned. Annotations require Oracle Database version 23, or later. If
        using python-oracledb Thick mode, Oracle Client version 23 or later is
        also required.
        )r9   annotationsr1   r   r   r   rA   f   s   zFetchInfo.annotationsc                 C   s   | j jdkr
| j jS | j j}|tu s|tu s|tu s|tu r dS |tu s0|tu s0|t	u s0|t
u rN| j jrJ| j jd }| j jdkrH|| j jd 7 }|S d}|S dS )zR
        This read-only attribute returns the display size of the column.
        r      r      N)r9   max_sizedbtyper   r   r	   r
   r   r   r   r   r(   r)   )r   rE   r&   r   r   r   r&   s   s(   zFetchInfo.display_sizec                 C   r@   )am  
        This read-only attribute returns the name of the `data use case
        domain
        <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-17D3A9C6
        -D993-4E94-BF6B-CACA56581F41>`__ associated with the fetched column. If
        there is no data use case domain, the value *None* is returned. `Data
        use case domains <https://www.oracle.com/pls/topic/lookup?ctx=dblatest
        &id=GUID-4743FDE1-7C6E-471B-BC9D-442383CCA2F9>`__ require Oracle
        Database version 23, or later. If using python-oracledb Thick mode,
        Oracle Client version 23 or later is also required.
        )r9   domain_namer1   r   r   r   rF      s   zFetchInfo.domain_namec                 C   r@   )ag  
        This read-only attribute returns the schema of the `data use case
        domain <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-
        17D3A9C6-D993-4E94-BF6B-CACA56581F41>`__ associated with the fetched
        column. If there is no data use case domain, the value *None* is
        returned. `Data use case domains <https://www.oracle.com/pls/topic/
        lookup?ctx=dblatest&id=GUID-4743FDE1-7C6E-471B-BC9D-442383CCA2F9>`__
        require Oracle Database version 23, or later. If using python-oracledb
        Thick mode, Oracle Client version 23 or later is also required.
        )r9   domain_schemar1   r   r   r   rG      s   zFetchInfo.domain_schemac                 C   s   | j jdkr
| j jS dS )z
        This read-only attribute returns the internal size of the column as
        mandated by the Python Database API.
        r   N)r9   rD   buffer_sizer1   r   r   r   r'      s   zFetchInfo.internal_sizec                 C   r@   )a  
        This read-only attribute returns whether the column is known to contain
        JSON data. This will be *True* when the type code is
        :data:`oracledb.DB_TYPE_JSON` as well as when an "IS JSON" constraint
        is enabled on LOB and VARCHAR2 columns.
        )r9   is_jsonr1   r   r   r   rI      s   zFetchInfo.is_jsonc                 C   r@   )a[  
        This read-only attribute returns whether the column is known to contain
        binary encoded `OSON <https://www.oracle.com/pls/topic/lookup?ctx=
        dblatest&id=GUID-911D302C-CFAF-406B-B6A5-4E99DD38ABAD>`__ data. This
        will be *True* when an "IS JSON FORMAT OSON" check constraint is
        enabled on BLOB columns.
        )r9   is_osonr1   r   r   r   rJ      s   	zFetchInfo.is_osonc                 C   r@   )zy
        This read-only attribute returns the name of the column as mandated by
        the Python Database API.
        )r9   r$   r1   r   r   r   r$         zFetchInfo.namec                 C   r@   )z
        This read-only attribute returns whether nulls are allowed in the
        column as mandated by the Python Database API.
        )r9   nulls_allowedr1   r   r   r   r*      rK   zFetchInfo.null_okc                 C   s   | j js| j jr| j jS dS )z~
        This read-only attribute returns the precision of the column as
        mandated by the Python Database API.
        Nr9   r(   r)   r1   r   r   r   r(         zFetchInfo.precisionc                 C   s   | j js| j jr| j jS dS )zz
        This read-only attribute returns the scale of the column as mandated by
        the Python Database API.
        NrM   r1   r   r   r   r)      rN   zFetchInfo.scalec                 C   s<   | j du r| jjdurt| jj| _ | j S | jj| _ | j S )a)  
        This read-only attribute returns the type of the column. This will be
        an :ref:`Oracle Object Type <dbobjecttype>` if the column contains
        Oracle objects; otherwise, it will be one of the
        :ref:`database type constants <dbtypes>` defined at the module level.
        N)r:   r9   objtyper   r>   rE   r1   r   r   r   type   s   

zFetchInfo.typec                 C   r@   )z
        This read-only attribute returns the type of the column as mandated by
        the Python Database API. The type will be one of the
        :ref:`database type constants <dbtypes>` defined at the module level.
        )r9   rE   r1   r   r   r   r%      s   zFetchInfo.type_codec                 C   s.   | j jtu r| j j}|tj@ s| j jS dS dS )z
        This read-only attribute returns the number of dimensions required by
        VECTOR columns. If the column is not a VECTOR column or allows for any
        number of dimensions, the value returned is *None*.
        N)r9   rE   r   vector_flagsr   VECTOR_META_FLAG_FLEXIBLE_DIMvector_dimensionsr   flagsr   r   r   rS     s   
zFetchInfo.vector_dimensionsc                 C   s.   | j jtu r| j jdkrt| j jS dS dS )a  
        This read-only attribute returns the storage type used by VECTOR
        columns. The value of this attribute can be:

        - :data:`oracledb.VECTOR_FORMAT_BINARY` which represents 8-bit unsigned
          integers
        - :data:`oracledb.VECTOR_FORMAT_INT8` which represents 8-bit signed
          integers
        - :data:`oracledb.VECTOR_FORMAT_FLOAT32` which represents 32-bit
          floating-point numbers
        - :data:`oracledb.VECTOR_FORMAT_FLOAT64` which represents 64-bit
          floating-point numbers

        If the column is not a VECTOR column or allows for any type of storage,
        the value returned is *None*.
        r   N)r9   rE   r   vector_formatoracledbVectorFormatr1   r   r   r   rV     s
   zFetchInfo.vector_formatc                 C   s&   | j jtu r| j j}t|tj@ S dS )ap  
        This read-only attribute returns a boolean indicating if the vector is
        sparse or not.

        If the column contains vectors that are SPARSE, the value returned is
        *True*. If the column contains vectors that are DENSE, the value
        returned is *False*. If the column is not a VECTOR column, the value
        returned is *None*.
        N)r9   rE   r   rQ   boolr   VECTOR_META_FLAG_SPARSE_VECTORrT   r   r   r   vector_is_sparse)  s   zFetchInfo.vector_is_sparse)%__name__
__module____qualname____doc__r   r-   r2   r5   r7   classmethodr>   propertyr   dictrA   intr&   r6   rF   rG   r'   rY   rI   rJ   r$   r*   r(   r)   r   r   rP   r%   rS   rW   rX   rV   r[   r   r   r   r   r   5   sR    
	
r   )	metaclass)typingr   rW    r   baser   	base_implr   r   r   r	   r
   r   r   r   r   r   dbobjectr   r   r   r   r   r   <module>   s   0