U kf@sdZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z d d l m Z d d l m Zd d l m Z d dl mZd dl mZerd dlmZd dlmZd dlmZe dedZeefZGdddejZeZGdddejZGdddejZGdddejZ GdddejZ!Gdd d eZ"Gd!d"d"eZ#Gd#d$d$ejZ$Gd%d&d&ejZ%Gd'd(d(ejZ&d)d*d+d,d-Z'e (d.d)d/d+d0d1Z)d2S)3zSQLAlchemy ORM exceptions.) annotations)Any)Optional)Tuple)Type) TYPE_CHECKING)TypeVar)_mapper_property_as_plain_name)exc)util)MultipleResultsFound) NoResultFound)LoaderStrategy)MapperProperty) InstanceState_T)boundc@seZdZdZdS)StaleDataErroraaAn operation encountered database state that is unaccounted for. Conditions which cause this to happen include: * A flush may have attempted to update or delete rows and an unexpected number of rows were matched during the UPDATE or DELETE statement. Note that when version_id_col is used, rows in UPDATE or DELETE statements are also matched against the current known version identifier. * A mapped object with version_id_col was refreshed, and the version number coming back from the database does not match that of the object itself. * A object is detached from its parent object, however the object was previously attached to a different parent identity which was garbage collected, and a decision cannot be made if the new parent was really the most recent "parent". N__name__ __module__ __qualname____doc__rrB/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/orm/exc.pyr$src@seZdZdZdS) FlushErrorz0A invalid condition was detected during flush().Nrrrrrr@src@seZdZdZdS) UnmappedErrorz?Base for exceptions that involve expected mappings not present.NrrrrrrDsrc@seZdZdZdS)ObjectDereferencedErrorzPAn operation cannot complete due to an object being garbage collected. NrrrrrrHsrc@seZdZdZdZdS)DetachedInstanceErrorzSAn attempt to access unloaded attributes on a mapped instance that is detached.Zbhk3N)rrrrcoderrrrr Osr c@s:eZdZdZedd dddddZd d d d ZdS)UnmappedInstanceErrorz;An mapping operation was requested for an unknown instance.sqlalchemy.orm.baseNobject Optional[str])objmsgcCstjj}|szz*|t|tt|}d||f}WnBtk rxdtt|d}t|trt|dt|7}YnXt ||dS)NzClass %r is mapped, but this instance lacks instrumentation. This occurs when the instance is created before sqlalchemy.orm.mapper(%s) was called.Class '' is not mappedz;; was a class (%s) supplied where an instance was required?) r preloadedorm_baseZ class_mappertype_safe_cls_nameUnmappedClassError isinstancer__init__)selfr&r'basenamerrrr0Ys$   zUnmappedInstanceError.__init__rreturncCs|jd|jdffSNr __class__argsr1rrr __reduce__psz UnmappedInstanceError.__reduce__)Nrrrrr preload_moduler0r;rrrrr"Vsr"c@s0eZdZdZd dddddZdd d d ZdS) r.z8An mapping operation was requested for an unknown class.NzType[_T]r%)clsr'cCs|s t|}t||dS)N)_default_unmappedrr0)r1r>r'rrrr0wszUnmappedClassError.__init__rr4cCs|jd|jdffSr6r7r:rrrr;|szUnmappedClassError.__reduce__)N)rrrrr0r;rrrrr.tsr.c@s:eZdZdZedd dddddZd d d d ZdS)ObjectDeletedErroraA refresh operation failed to retrieve the database row corresponding to an object's known primary key identity. A refresh operation proceeds when an expired attribute is accessed on an object, or when :meth:`_query.Query.get` is used to retrieve an object which is, upon retrieval, detected as expired. A SELECT is emitted for the target row based on primary key; if no row is returned, this exception is raised. The true meaning of this exception is simply that no row exists for the primary key identifier associated with a persistent object. The row may have been deleted, or in some cases the primary key updated to a new value, outside of the ORM's management of the target object. r#NzInstanceState[Any]r%)stater'cCs,tjj}|sd||}tj||dS)NzDInstance '%s' has been deleted, or its row is otherwise not present.)r r*r+Z state_strsa_excInvalidRequestErrorr0)r1rAr'r2rrrr0szObjectDeletedError.__init__rr4cCs|jd|jdffSr6r7r:rrrr;szObjectDeletedError.__reduce__)Nr<rrrrr@s r@c@seZdZdZdS)UnmappedColumnErrorz5Mapping operation was requested on an unknown column.NrrrrrrDsrDc@s&eZdZdZdddddddd Zd S) LoaderStrategyExceptionz2A loader strategy for an attribute does not exist. Type[Any]zMapperProperty[Any]z#Optional[Type[MapperProperty[Any]]]zOptional[Type[LoaderStrategy]]zTuple[Any, ...])applied_to_property_typerequesting_property applies_toactual_strategy_type strategy_keyc CsX|dkr tj|d||fn4|dk s,ttj|dt||t|t|fdS)NzCan't find strategy %s for %szuCan't apply "%s" strategy to property "%s", which is a "%s"; this loader strategy is intended to be used with a "%s".)rBrCr0AssertionErrorr Zclsname_as_plain_namer )r1rGrHrIrJrKrrrr0s$ z LoaderStrategyException.__init__N)rrrrr0rrrrrEsrErFstr)r>r5cCsLzd|j|jf}Wn0tk rFt|dd}|dkrBt|}YnX|S)N.r)joinrrAttributeErrorgetattrrepr)r>cls_namerrrr-s r-r#r%c CsZtjj}z||j}Wn ttftk r8i}YnXt|}|sRd|dSdSdS)Nr(r)) r r*r+Zmanager_of_classmappersr. TypeErrorNO_STATEr-)r>r2rTr3rrrr?s   r?N)*r __future__rtypingrrrrrrr r r rBrrZ interfacesrrrArrrPKeyErrorrVZSQLAlchemyErrorrZConcurrentModificationErrorrrCrrr r"r.r@rDrEr-r=r?rrrrs@                 $!