o znh@sdZddlmZddlmZeefZ GdddejZ e Z GdddejZ Gdd d ej Z Gd d d ejZGd d d ejZGddde ZGddde ZGdddej ZGdddej ZGdddej ZGdddej ZGdddej ZddZeddd Zd!S)"zSQLAlchemy ORM exceptions.)exc)utilc@eZdZdZdS)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__r r =/usr/local/lib/python3.10/dist-packages/sqlalchemy/orm/exc.pyrrc@r) FlushErrorz0A invalid condition was detected during flush().Nrr r r r r-r rc@r) UnmappedErrorz?Base for exceptions that involve expected mappings not present.Nrr r r r r1r rc@r)ObjectDereferencedErrorzPAn operation cannot complete due to an object being garbage collected. Nrr r r r r5r rc@seZdZdZdZdS)DetachedInstanceErrorzSAn attempt to access unloaded attributes on a mapped instance that is detached.bhk3N)rrr r coder r r r r<src@,eZdZdZeddddZddZdS) UnmappedInstanceErrorz;An mapping operation was requested for an unknown instance.sqlalchemy.orm.baseNcCsx|s4z|t|tt|}d||f}Wnty3tt|}t|tr1|dt|7}Ynwt||dS)NzClass %r is mapped, but this instance lacks instrumentation. This occurs when the instance is created before sqlalchemy.orm.mapper(%s) was called.z;; was a class (%s) supplied where an instance was required?) class_mappertype_safe_cls_nameUnmappedClassError_default_unmapped isinstancer__init__)selfbaseobjmsgnamer r r rFs&    zUnmappedInstanceError.__init__cC|jd|jdffSN __class__argsrr r r __reduce__[z UnmappedInstanceError.__reduce__Nrrr r r dependenciesrr*r r r r rCs   rc@s"eZdZdZdddZddZdS)rz8An mapping operation was requested for an unknown class.NcCs|st|}t||dSr,)rrr)rclsr!r r r rbszUnmappedClassError.__init__cCr#r$r&r)r r r r*gr+zUnmappedClassError.__reduce__r,)rrr r rr*r r r r r_s  rc@r) 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.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. rNcCs$|s d||}tj||dS)NzDInstance '%s' has been deleted, or its row is otherwise not present.) state_strsa_excInvalidRequestErrorr)rrstater!r r r rs zObjectDeletedError.__init__cCr#r$r&r)r r r r*r+zObjectDeletedError.__reduce__r,r-r r r r r0ks   r0c@r)UnmappedColumnErrorz5Mapping operation was requested on an unknown column.Nrr r r r r5r r5c@r) NoResultFoundz2A database result was required but none was found.Nrr r r r r6r r6c@r)MultipleResultsFoundzCA single database result was required but more than one were found.Nrr r r r r7r r7c@seZdZdZddZdS)LoaderStrategyExceptionz2A loader strategy for an attribute does not exist.c CsR|durtj|d||fdStj|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".)r2r3rrclsname_as_plain_name)rapplied_to_property_typerequesting_property applies_toactual_strategy_type strategy_keyr r r rs"z LoaderStrategyException.__init__N)rrr r rr r r r r8s r8cCsPz d|j|jf}W|Sty't|dd}|dur$t|}Y|SY|Sw)N.r)joinrrAttributeErrorgetattrrepr)r/cls_namer r r rs  rrcCsTz||j}Wntyi}Yn tyi}Ynwt|}|s(d|SdS)NzClass '%s' is not mapped)manager_of_classmappersNO_STATE TypeErrorr)rr/rFr"r r r rs  rN)r rr2rrAKeyErrorrGSQLAlchemyErrorrConcurrentModificationErrorrr3rrrrrr0r5r6r7r8rr.rr r r r s*   "