
    i3                         d dl mZmZmZ ddlmZ ddlmZ ddlm	Z	  G d de          Z
 G d	 d
e          Z G d de          ZdS )    )AnySequenceUnion   )errors)BaseMetaClass)DbTypec                   @    e Zd Z fdZd Zd Z fdZd Zed             Z	de
dd	fd
ZdefdZdefdZddZdedd	fdZdedefdZdedd	fdZdefdZdede
fdZdefdZdedefdZdedefdZdede
dd	fdZdefdZdedd	fdZed d            Z xZ S )!DbObjectc                     	 | j         j        j        |         }n1# t          $ r$ t	                                          |          cY S w xY w| j                             |          S N)_impltypeattrs_by_nameKeyErrorsuper__getattribute__get_attr_value)selfname	attr_impl	__class__s      a/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/oracledb/dbobject.py__getattr__zDbObject.__getattr__)   sj    	2
5d;II 	2 	2 	277++D11111	2z((333s    +A	A	c              #      K   |                                   | j                                        }|:| j                            |          V  | j                            |          }|8d S d S r   _ensure_is_collectionr   get_first_indexget_element_by_indexget_next_index)r   ixs     r   __iter__zDbObject.__iter__0   sp      ""$$$Z''))n*11"55555**2..B nnnnn    c           
          | j         j        }d| d| j                                         dt	          t          |                      dS )N< z at >)r   _public_namer   _get_full_namehexid)r   cls_names     r   __repr__zDbObject.__repr__7   sG    >.N8NNdi6688NNc"T((mmNNNNr#   c                     |dk    s|dk    r$t                                          ||           d S | j        j        j        |         }| j                            ||           d S )Nr   _type)r   __setattr__r   r   r   set_attr_value)r   r   valuer   r   s       r   r0   zDbObject.__setattr__;   sc    7??dgooGGe,,,,,
5d;IJ%%i77777r#   c                     | j         j        s9t          j        t          j        | j                                                    dS dS )zi
        Ensures that the object refers to a collection. If not, an exception is
        raised.
        r   N)r   iscollectionr   
_raise_errERR_OBJECT_IS_NOT_A_COLLECTIONr)   r   s    r   r   zDbObject._ensure_is_collectionB   sV    
 y% 	5Y--//     	 	r#   c                 L    |                      |           }||_        d |_        |S r   __new__r   r/   )clsimplobjs      r   
_from_implzDbObject._from_implM   s&    kk#		
r#   elementreturnNc                 b    |                                   | j                            |           dS )a  
        Appends an element to the collection object. If no elements exist in
        the collection, this creates an element at index 0; otherwise, it
        creates an element immediately following the highest index available in
        the collection.
        N)r   r   append)r   r@   s     r   rC   zDbObject.appendT   s2     	""$$$
'"""""r#   c                     |                                   i }| j                                        }|9| j                            |          ||<   | j                            |          }|9|S )u}   
        Returns a dictionary where the collection’s indexes are the keys and
        the elements are its values.
        r   )r   resultr!   s      r   asdictzDbObject.asdict^   so    
 	""$$$Z''))n88<<F2J**2..B n r#   c                      t          |           S )uW   
        Returns a list of each of the collection’s elements in index order.
        )listr8   s    r   aslistzDbObject.aslistk   s     Dzzr#   c                 h    | j                                         }t                              |          S )z>
        Creates a copy of the object and returns it.
        )r   copyr   r?   )r   copied_impls     r   rK   zDbObject.copyq   s)     joo''"";///r#   indexc                 b    |                                   | j                            |           dS )aR  
        Delete the element at the specified index of the collection. If the
        element does not exist or is otherwise invalid, an error is raised.
        Note that the indices of the remaining elements in the collection are
        not changed. In other words, the delete operation creates holes in the
        collection.
        N)r   r   delete_by_indexr   rM   s     r   deletezDbObject.deletex   s2     	""$$$
""5)))))r#   c                 ^    |                                   | j                            |          S )zx
        Return True or False indicating if an element exists in the collection
        at the specified index.
        )r   r   exists_by_indexrP   s     r   existszDbObject.exists   s,    
 	""$$$z))%000r#   seqc                 b    |                                   |D ]}|                     |           dS )z
        Appends all of the elements in the sequence to the collection. This is
        the equivalent of performing append() for each element found in the
        sequence.
        N)r   rC   )r   rU   r2   s      r   extendzDbObject.extend   sD     	""$$$ 	 	EKK	 	r#   c                 \    |                                   | j                                        S )z
        Returns the index of the first element in the collection. If the
        collection is empty, None is returned.
        )r   r   r   r8   s    r   firstzDbObject.first   s*    
 	""$$$z))+++r#   c                 ^    |                                   | j                            |          S )z
        Returns the element at the specified index of the collection. If no
        element exists at that index, an exception is raised.
        )r   r   r   rP   s     r   
getelementzDbObject.getelement   s,    
 	""$$$z..u555r#   c                 \    |                                   | j                                        S )z
        Returns the index of the last element in the collection. If the
        collection is empty, None is returned.
        )r   r   get_last_indexr8   s    r   lastzDbObject.last   s*    
 	""$$$z((***r#   c                 ^    |                                   | j                            |          S )z
        Returns the index of the next element in the collection following the
        specified index. If there are no elements in the collection following
        the specified index, None is returned.
        )r   r   r    rP   s     r   nextzDbObject.next   ,     	""$$$z((///r#   c                 ^    |                                   | j                            |          S )z
        Returns the index of the element in the collection preceding the
        specified index. If there are no elements in the collection preceding
        the specified index, None is returned.
        )r   r   get_prev_indexrP   s     r   prevzDbObject.prev   ra   r#   r2   c                 d    |                                   | j                            ||           dS )ze
        Sets the value in the collection at the specified index to the given
        value.
        N)r   r   set_element_by_index)r   rM   r2   s      r   
setelementzDbObject.setelement   s4    
 	""$$$
''u55555r#   c                 \    |                                   | j                                        S )zC
        Returns the number of elements in the collection.
        )r   r   get_sizer8   s    r   sizezDbObject.size   s*     	""$$$z""$$$r#   numc                 b    |                                   | j                            |           dS )zb
        Removes the specified number of elements from the end of the
        collection.
        N)r   r   trim)r   rk   s     r   rm   zDbObject.trim   s0    
 	""$$$
r#   DbObjectTypec                 p    | j         )t                              | j        j                  | _         | j         S )zq
        This read-only attribute arturns an ObjectType corresponding to the
        type of the object.
        )r/   rn   r?   r   r   r8   s    r   r   zDbObject.type   s-     :%00AADJzr#   )rA   r   )rA   rn   )!__name__
__module____qualname__r   r"   r-   r0   r   classmethodr?   r   rC   dictrF   rH   rI   rK   intrQ   boolrT   rW   rY   r[   r^   r`   rd   rg   rj   rm   propertyr   __classcell__)r   s   @r   r   r   '   s       4 4 4 4 4/ / /O O O8 8 8 8 8	 	 	   [#c #d # # # #        0 0 0 0	*C 	*D 	* 	* 	* 	*1C 1D 1 1 1 1$ 4    ,s , , , ,6 6 6 6 6 6+c + + + +0# 0# 0 0 0 00# 0# 0 0 0 06 6C 6D 6 6 6 6%c % % % %         X    r#   r   )	metaclassc                       e Zd Zd Zed             Zedeedf         fd            Z	ede
fd            Zedeedf         fd            Zedeedf         fd            Zeded	ef         fd
            ZdS )DbObjectAttrc                     d| j          dS )Nz<oracledb.DbObjectAttr r'   r4   r8   s    r   r-   zDbObjectAttr.__repr__   s    55555r#   c                 L    |                      |           }||_        d |_        |S r   r:   )r<   r=   attrs      r   r?   zDbObjectAttr._from_impl   s&    {{3

r#   rA   Nc                 6    | j         j        r| j         j        S dS )a  
        This read-only attribute returns the maximum size (in bytes) of the
        attribute when the attribute's type is one of
        DB_TYPE_RAW, DB_TYPE_CHAR, DB_TYPE_NCHAR, DB_TYPE_VARCHAR and
        DB_TYPE_NVARCHAR. For all other types, the value returned is None.
        N)r   max_sizer8   s    r   r   zDbObjectAttr.max_size   s&     : 	':&&	' 	'r#   c                     | j         j        S )zM
        This read-only attribute returns the name of the attribute.
        r   r   r8   s    r   r   zDbObjectAttr.name       
 zr#   c                 N    | j         j        s| j         j        r| j         j        S dS )z
        This read-only attribute returns the precision of the attribute when
        the attribute's type is DB_TYPE_NUMBER. For all other types, the value
        returned is None.
        Nr   	precisionscaler8   s    r   r   zDbObjectAttr.precision   s2     : 	(4:#3 	(:''	( 	(r#   c                 N    | j         j        s| j         j        r| j         j        S dS )z
        This read-only attribute returns the scale of the attribute when the
        attribute's type is DB_TYPE_NUMBER. For all other types, the value
        returned is None.
        Nr   r8   s    r   r   zDbObjectAttr.scale	  s2     : 	$4:#3 	$:##	$ 	$r#   rn   c                     | j         G| j        j        *t                              | j        j                  | _         n| j        j        | _         | j         S )z
        This read-only attribute returns the type of the attribute. This will
        be an Oracle Object Type if the variable binds Oracle objects;
        otherwise, it will be one of the database type constants.
        )r/   r   objtypern   r?   dbtyper8   s    r   r   zDbObjectAttr.type  sG     :z!-)44TZ5GHH

!Z.
zr#   )rp   rq   rr   r-   rs   r?   rw   r   ru   r   strr   r   r   r	   r    r#   r   r{   r{      s&       6 6 6   [ '%T	* ' ' ' X' c    X (5d+ ( ( ( X( $uS$Y' $ $ $ X$ eNF23    X  r#   r{   c                      e Zd ZddedefdZd Zd Zed             Z	d Z
eded	         fd
            Zedefd            Zedefd            Zeded ef         fd            ZddedefdZedefd            Zedefd            ZdS )rn   Nr2   rA   c                 ,    |                      |          S )z
        The object type may be called directly and serves as an alternative way
        of calling :meth:`~DbObjectType.newobject()`.
        )	newobject)r   r2   s     r   __call__zDbObjectType.__call__$  s    
 ~~e$$$r#   c                 Z    t          |t                    r|j        | j        k    S t          S r   )
isinstancern   r   NotImplemented)r   others     r   __eq__zDbObjectType.__eq__+  s)    e\** 	-;$*,,r#   c                 2    d|                                   dS )Nz<oracledb.DbObjectType r'   )r)   r8   s    r   r-   zDbObjectType.__repr__0  s    A)<)<)>)>AAAAr#   c                 Z    |                      |           }||_        d |_        d |_        |S r   )r;   r   _attributes_element_type)r<   r=   typs      r   r?   zDbObjectType._from_impl3  s.    kk#	 
r#   c                 4    | j                                         S )z4
        Returns the full name of the type.
        )r   _get_fqnr8   s    r   r)   zDbObjectType._get_full_name;  s     z""$$$r#   r{   c                 T    | j         d | j        j        D             | _         | j         S )zq
        This read-only attribute returns a list of the attributes that make up
        the object type.
        Nc                 B    g | ]}t                               |          S r   )r{   r?   ).0is     r   
<listcomp>z+DbObjectType.attributes.<locals>.<listcomp>H  s3          /0''**     r#   )r   r   attrsr8   s    r   
attributeszDbObjectType.attributesA  s>     #   48J4D     D r#   c                     | j         j        S )z
        This read-only attribute returns a boolean indicating if the object
        type refers to a collection or not.
        )r   is_collectionr8   s    r   r5   zDbObjectType.iscollectionM  s     z''r#   c                     | j         j        S )zH
        This read-only attribute returns the name of the type.
        r   r8   s    r   r   zDbObjectType.nameU  r   r#   c                     | j         X| j        j        j        1| j        j        j        }t                              |          | _         n| j        j        j        | _         | j         S )a7  
        This read-only attribute returns the type of elements found in
        collections of this type, if iscollection is True; otherwise, it
        returns None. If the collection contains objects, this will be another
        object type; otherwise, it will be one of the database type constants.
        )r   r   element_metadatar   rn   r?   r   )r   typ_impls     r   element_typezDbObjectType.element_type\  sZ     %z*2>:6>%1%<%<X%F%F""%)Z%@%G"!!r#   c                     | j                                         }t                              |          }||                    |           |S )a_  
        Returns a new Oracle object of the given type. This object can then be
        modified by setting its attributes and then bound to a cursor for
        interaction with Oracle. If the object type refers to a collection, a
        sequence may be passed and the collection will be initialized with the
        items in that sequence.
        )r   create_new_objectr   r?   rW   )r   r2   obj_implr>   s       r   r   zDbObjectType.newobjectl  sG     ://11!!(++JJu
r#   c                     | j         j        S )z
        This read-only attribute returns the name of the package containing the
        PL/SQL type or None if the type is not a PL/SQL type.
        )r   package_namer8   s    r   r   zDbObjectType.package_namez  s     z&&r#   c                     | j         j        S )ze
        This read-only attribute returns the name of the schema that owns the
        type.
        )r   schemar8   s    r   r   zDbObjectType.schema  s     z  r#   r   )rp   rq   rr   r   r   r   r   r-   rs   r?   r)   rw   rH   r   rv   r5   r   r   r   r	   r   r   r   r   r   r#   r   rn   rn   "  s       % %h %( % % % %  
B B B   [% % % 	 D0 	  	  	  X	  (d ( ( ( X( c    X "eNF$:; " " " X" x 8     'c ' ' ' X' ! ! ! ! X! ! !r#   rn   N)typingr   r   r    r   baser   	base_implr	   r   r{   rn   r   r#   r   <module>r      s	  @ ( ' ' ' ' ' ' ' ' '                  w w w w w w w w wt> > > > >] > > > >Bf! f! f! f! f!] f! f! f! f! f! f!r#   