B 4]:@s dZddlZddlmZddlmZddlmZddlmZddlmZe d d Z e d d Z e d dZ e ddZ e ddZej ddddZej ddddZej ddddZej ddddZej ddddZej d d!d"dZej d#d$d%dZej d&d'd(dZej d)d*d+dZej d,d-eeBeBeBeBdZej d.d/eeAdZej d0d1eeAdZej d2d3eeAdZej d4d5eeAdZej d6d7eeAdZd8Zd9Zd:Z e d;Z!e d<Z"e d=Z#e d>d?Z$e d@dAZ%e dBdCZ&e dDdEZ'e(egZ)e(dee gZ*e dFZ+e dGZ,dHdIZ-dJdKZ.e/eZ0e/dLZ1dMdNZ2dOdPZ3dQdRZ4dSdTZ5dUdVZ6dWdXZ7dYdZZ8e9e:d[d\Z;d]d^ZdcddZ?dedfZ@dgdhZAdidjZBeCdkZDe9eEdxdmdnZFdydpdqZGGdrdsdse:ZHGdtdudueHZIGdvdwdwe:ZJdS)zz=Constants and rudimental functions used throughout the ORM. N)exc) inspection)util) expressionPASSIVE_NO_RESULTzSymbol returned by a loader callable or other attribute/history retrieval operation when a value could not be determined, based on loader callable flags. ATTR_WAS_SETzSymbol returned by a loader callable to indicate the retrieved value, or values, were assigned to their attributes on the target object. ATTR_EMPTYz@Symbol used internally to indicate an attribute had no callable.NO_VALUEzSymbol which may be placed as the 'previous' value of an attribute, indicating no value was loaded for an attribute when it was modified, and flags indicated we were not to load it. NEVER_SETzSymbol which may be placed as the 'previous' value of an attribute indicating that the attribute had not been assigned to previously. NO_CHANGEz]No callables or SQL should be emitted on attribute access and no state should change )Z canonical CALLABLES_OKzELoader callables can be fired off if a value is not present. SQL_OKzBLoader callables can emit SQL at least on scalar value attributes.RELATED_OBJECT_OKzZCallables can use SQL to load related objects as well as scalar value attributes. INIT_OKzAttributes should be initialized with a blank value (None or an empty collection) upon get, if no other value can be obtained. NON_PERSISTENT_OKz9Callables can be emitted if the parent is not persistent.LOAD_AGAINST_COMMITTEDzUCallables should use committed values as primary/foreign keys during a load. NO_AUTOFLUSHz*Loader callables should disable autoflush.@NO_RAISEz0Loader callables should not raise any assertions PASSIVE_OFFz&Callables can be emitted in all cases.PASSIVE_RETURN_NEVER_SETzPASSIVE_OFF ^ INIT_OKPASSIVE_NO_INITIALIZEz'PASSIVE_RETURN_NEVER_SET ^ CALLABLES_OKPASSIVE_NO_FETCHzPASSIVE_OFF ^ SQL_OKPASSIVE_NO_FETCH_RELATEDzPASSIVE_OFF ^ RELATED_OBJECT_OKPASSIVE_ONLY_PERSISTENTzPASSIVE_OFF ^ NON_PERSISTENT_OKZ_sa_class_managerZ_sa_instance_state)mapperZ instrumentor EXT_CONTINUEEXT_STOPEXT_SKIP ONETOMANYzIndicates the one-to-many direction for a :func:`.relationship`. This symbol is typically used by the internals but may be exposed within certain API features. MANYTOONEzIndicates the many-to-one direction for a :func:`.relationship`. This symbol is typically used by the internals but may be exposed within certain API features. MANYTOMANYzIndicates the many-to-many direction for a :func:`.relationship`. This symbol is typically used by the internals but may be exposed within certain API features. NOT_EXTENSIONzSymbol indicating an :class:`InspectionAttr` that's not part of sqlalchemy.ext. Is assigned to the :attr:`.InspectionAttr.extension_type` attribute. ZSET_DEFERRED_EXPIREDZDEFER_FOR_STATEcstjfdd}|S)z1Mark a method as generative, e.g. method-chained.csB|d}xD]}|||jqW||f|dd||S)Nrr)Z_clone__name__)fnargskwselfZ assertion) assertionsF/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/orm/base.pygenerates   z_generative..generate)rZ decorator)r/r2r0)r/r1 _generativesr3cCs|jtdS)N)__dict__getDEFAULT_MANAGER_ATTR)clsr0r0r1manager_of_classsr8r4cCs tt|S)z'Return a string describing an instance.) state_strinstance_state)instancer0r0r1 instance_strsr<cCs(|dkr dSd|jjt|fSdS)z=Return a string describing an instance via its InstanceState.NNonez <%s at 0x%x>)class_r*idobj)stater0r0r1r9sr9cCs|dkr dSd|jjfSdS)zNReturn a string describing an instance's class via its InstanceState. Nr=z<%s>)r>r*)rAr0r0r1state_class_strsrBcCst|d|S)N.)r<)r; attributer0r0r1 attribute_strsrEcCst|d|S)NrC)r9)rArDr0r0r1state_attribute_str srFcCs t|jS)aGiven an object, return the primary Mapper associated with the object instance. Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError` if no mapping is configured. This function is available via the inspection system as:: inspect(instance).mapper Using the inspection system will raise :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is not part of a mapping. ) object_stater")r;r0r0r1 object_mappersrHcCs$t|}|dkrt|n|SdS)aGiven an object, return the :class:`.InstanceState` associated with the object. Raises :class:`sqlalchemy.orm.exc.UnmappedInstanceError` if no mapping is configured. Equivalent functionality is available via the :func:`.inspect` function as:: inspect(instance) Using the inspection system will raise :class:`sqlalchemy.exc.NoInspectionAvailable` if the instance is not part of a mapping. N)_inspect_mapped_objectrZUnmappedInstanceError)r;rAr0r0r1rG"s rGcCs8yt|Stjk rdStjk r2dSXdS)N)r:rUnmappedClassErrorNO_STATE)r;r0r0r1rI:s rIcCs(t|d}|dk r|jSt|dS)NF)rinspectr"rrJ)Zclass_or_mapperinspr0r0r1_class_to_mapperFs rNcCs"t|d}|dk r|jSdSdS)z\Return the :class:`.Mapper` for the given class or None if the class is not mapped. FN)rrLr")entityrMr0r0r1_mapper_or_noneNs rPcCs(t|d}|dk o&|j o&|jp&|jS)zhReturn True if the given object is a mapped class, :class:`.Mapper`, or :class:`.AliasedClass`. FN)rrLis_clause_element is_mapperis_aliased_class)rOrMr0r0r1_is_mapped_classZs rTcCst|dr|jSt|SdS)Nkey)hasattrrUrZ_column_as_key)attrr0r0r1 _attr_as_keygs rXcCs>t|d}t|dr4t|jdr4dd|jjDS|gSdS)NF selectableccSsg|]}|qSr0r0).0rZr0r0r1 qsz _orm_columns..)rrLrVrYrZ)rOrMr0r0r1 _orm_columnsns r]cCs t|d}|dk ot|ddS)NFrS)rrLgetattr)rOrMr0r0r1_is_aliased_classvs r_cCst|}|jr|}|j}n.|jr.|j}|}nt|drF|jj}}n|}y t ||St k rzt d||fYnXdS)zReturn a class attribute given an entity and string name. May return :class:`.InstrumentedAttribute` or user-defined attribute. r"z Entity '%s' has no property '%s'N) rrL is_selectablerZrSrOrVr"r>r^AttributeErrorsa_excZInvalidRequestError)rOrUrM descriptionr0r0r1_entity_descriptor{s   rdzmanager.mapperFcCsNyt|}|jsdS|j}Wntjk r2dSX|rF|jrF||SdS)N)r8Z is_mappedr"rrKZ _new_mappersZ_configure_all)r> configureZ class_managerr"r0r0r1_inspect_mapped_classs  rfTcCsBt||d}|dkr:t|ts.td|ft|n|SdS)aGiven a class, return the primary :class:`.Mapper` associated with the key. Raises :exc:`.UnmappedClassError` if no mapping is configured on the given class, or :exc:`.ArgumentError` if a non-class object is passed. Equivalent functionality is available via the :func:`.inspect` function as:: inspect(some_mapped_class) Using the inspection system will raise :class:`sqlalchemy.exc.NoInspectionAvailable` if the class is not mapped. )reNz Class object expected, got '%r'.)rf isinstancetyperbZ ArgumentErrorrrJ)r>rer"r0r0r1 class_mappers    ric@s8eZdZdZdZdZdZdZdZdZ dZ dZ dZ e ZdS)InspectionAttra A base class applied to all ORM objects that can be returned by the :func:`.inspect` function. The attributes defined here allow the usage of simple boolean checks to test basic facts about the object returned. While the boolean checks here are basically the same as using the Python isinstance() function, the flags here can be used without the need to import all of these classes, and also such that the SQLAlchemy class system can change while leaving the flags here intact for forwards-compatibility. r0FN)r* __module__ __qualname____doc__ __slots__r`rSZ is_instancerRZ is_propertyZ is_attributeZ_is_internal_proxyrQr)Zextension_typer0r0r0r1rjs  rjc@seZdZdZejddZdS)InspectionAttrInfoaAdds the ``.info`` attribute to :class:`.InspectionAttr`. The rationale for :class:`.InspectionAttr` vs. :class:`.InspectionAttrInfo` is that the former is compatible as a mixin for classes that specify ``__slots__``; this is essentially an implementation artifact. cCsiS)aInfo dictionary associated with the object, allowing user-defined data to be associated with this :class:`.InspectionAttr`. The dictionary is generated when first accessed. Alternatively, it can be specified as a constructor argument to the :func:`.column_property`, :func:`.relationship`, or :func:`.composite` functions. .. versionchanged:: 1.0.0 :attr:`.MapperProperty.info` is also available on extension types via the :attr:`.InspectionAttrInfo.info` attribute, so that it can apply to a wider variety of ORM and extension constructs. .. seealso:: :attr:`.QueryableAttribute.info` :attr:`.SchemaItem.info` r0)r.r0r0r1infoszInspectionAttrInfo.infoN)r*rkrlrmrZmemoized_propertyrpr0r0r0r1ro sroc@seZdZdZdZdS)_MappedAttributezVMixin for attributes which should be replaced by mapper-assigned attributes. r0N)r*rkrlrmrnr0r0r0r1rq/srq)F)T)KrmoperatorrrbrrZsqlrZsymbolrr r r r r rrrrrrrrrrrrr r!r6ZDEFAULT_STATE_ATTRZ _INSTRUMENTORr#r$r%r&r'r(r) frozensetZ _never_setZ _none_setZ_SET_DEFERRED_EXPIREDZ_DEFER_FOR_STATEr3r8 attrgetterr:Z instance_dictr<r9rBrErFrHrGZ _inspectsobjectrIrNrPrTrXr]r_rdZ dottedgetterZ _state_mapperrhrfrirjrorqr0r0r0r1 s                         I"