gq dZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd lm Z dd lm Z dd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddl"m#Z#ddl$m%Z%d d!lm&Z'd d"lm(Z(d d#lm)Z)d d$lm$Z$d d%l*m+Z+d d&l*m,Z,d d'l-m.Z.d d(l/m0Z0d d)l/m1Z1d d*l2m3Z3d d+l4m5Z5d d,l4m6Z6d d-l4m7Z7d d.l4m8Z8d d/l4m9Z9d d0l4m:Z:d d1l4m;Z;e r`dd2lZ>dd4llMmOZOd d?lPmQZQd d@l4mRZRd dAl4mSZSedBeCZTedDeCZUedEdFCZVgdGZWe)jGdHdIeeTe!eTee)jZZGdJdKeZeTeeTZ[GdLdMeeeTeeTZ\yN)Oz|MapperProperty implementations. This is a private module which defines the behavior of individual ORM- mapped attributes. ) annotations)Any)cast)Dict)List)Optional)Sequence)Set)Tuple)Type) TYPE_CHECKING)TypeVar)Union) attributes)strategy_options)_DeclarativeMapped) class_mapper)CompositeProperty)ConcreteInheritedProperty)SynonymProperty)_AttributeOptions)_DEFAULT_ATTRIBUTE_OPTIONS)_IntrospectsAnnotations) _MapsColumns)MapperProperty)PropComparator)StrategizedProperty)RelationshipProperty)de_stringify_annotation)exc) ForeignKey)log)util) coercions)roles)_NoArg)Column) SchemaConst) TypeEngine)de_optionalize_union_types)get_args) includes_none) is_fwd_ref) is_pep593) is_pep695)Self)_IdentityKeyType) _InstanceDict)_ORMColumnExprArgument) _RegistryType)Mapped)_ClassScanMapperConfig)Mapper)Session)_InstallLoaderCallableProto) InstanceState) _InfoType) ColumnElement) NamedColumn) OperatorType)_AnnotationScanType)RODescriptorReference_T)bound_PT_NCzNamedColumn[Any])ColumnPropertyrrrrc (eZdZUdZej ZdZ dZde d<de d<de d <d e d <d Z d d ddd ddd d ddd d!fdZ d"dZ e d#dZe d$dZd%dZej$dd d&dZej$dd d&dZd'dZe d'dZd(dZd)fd Zd*dZ d+dZGddej6eeZd,d ZxZ S)-rGzDescribes an object attribute that corresponds to a table column or other column expression. Public constructor is the :func:`_orm.column_property` function. TFzList[NamedColumn[Any]]columnsbool_is_polymorphic_discriminator Optional[str]_mapped_by_synonymzType[PropComparator[_T]]comparator_factory)rIgroupdeferred instrumentrNactive_historyexpire_on_flush_creation_orderrKrM_deferred_column_loader_raise_column_loader_renders_in_subqueries raiseloadN) attribute_optionsrOrPrXrNrRrSinfodoc _instrument_assume_readonly_dc_attributesc t||| |f| z}|Dcgc]&}tjtj |(c}|_||_||_||_ | |_ ||n|jj|_ ||_||_| |j j#| | | |_n9t'|j D]}t)|dd} | | |_nd|_t+j,|d|jfd|jff|_|jr|xj.dz c_yycc}w)N)rYr]r[rPrQ))rXT)super__init__r&expectr'LabeledColumnExprRolerIrOrPrXrQ __class__ ComparatorrNrRrSrZupdater[reversedgetattrr%set_creation_order strategy_key)selfcolumnrYrOrPrXrNrRrSrZr[r\r]additional_columnsrIccolrcs J/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/properties.pyr`zColumnProperty.__init__sa /+I  )00FM FMI  U88! >   !7 7  G s+Ec p|jd} | j|| _| j|| _yyNr)rIkeyname) rj decl_scanregistryclsoriginating_modulerrmapped_container annotationextracted_mapped_annotationis_dataclass_fieldrks rodeclarative_scanzColumnProperty.declarative_scans8a :: FJ ;; FK c|SNrjs romapper_property_to_assignz(ColumnProperty.mapper_property_to_assigns r}c||jDcgc]"}t|tr|j|df$c}Scc}wrq)rI isinstancer)table)rjrms rocolumns_to_assignz ColumnProperty.columns_to_assignsC \\ !!V$F!   s'9cd|jvr|jjSd|jvxs||jjvS)N)query_expressionT)rPT)ristrategy_have_default_expressionparent_readonly_propsrs ro%_memoized_attr__renders_in_subqueriesz4ColumnProperty._memoized_attr__renders_in_subqueriessJ %):): :==99 9!):)::  33 3 r}zsqlalchemy.orm.statezsqlalchemy.orm.strategiesctjj}tjj}|jj |j j|j|j|jSr r% preloaded orm_stateorm_strategiesr<"_instance_level_callable_processorr class_managerLoadDeferredColumnsrrrjstate strategiess ro&_memoized_attr__deferred_column_loaderz5ColumnProperty._memoized_attr__deferred_column_loadersa((^^22 ""EE KK % %  * *488 4 HH  r}ctjj}tjj}|jj |j j|j|jd|jS)NTrrs ro#_memoized_attr__raise_column_loaderz2ColumnProperty._memoized_attr__raise_column_loadersc((^^22 ""EE KK % %  * *488T : HH  r}c|jS)zsAllow the ColumnProperty to work in expression before it is turned into an instrumented attribute. ) expressionrs ro__clause_element__z!ColumnProperty.__clause_element__s r}c |jdS)aReturn the primary column or expression for this ColumnProperty. E.g.:: class File(Base): # ... name = Column(String(64)) extension = Column(String(8)) filename = column_property(name + "." + extension) path = column_property("C:/" + filename.expression) .. seealso:: :ref:`mapper_column_property_sql_expressions_composed` r)rIrs rorzColumnProperty.expression s(||Ar}c|jsytj|j|j|j ||||j y)N) comparator parententityr[)rQrregister_descriptorclass_rrrNr[)rjmappers roinstrument_classzColumnProperty.instrument_class#sB && MM HH..tV<  r}c ft|t|jdkDrt |j j j|jrQtjd|j d|jdd|jdd|jd yyy)Nrz On mapper z, primary key column 'z6' is being combined with distinct primary key column 'rz' in attribute 'zM'. Use explicit properties to give each column its own mapped attribute name.) r_do_initlenrIsetr primary_key issupersetr%warnrr)rjrcs rorzColumnProperty.do_init/s  t|| q S)@)@%A%L%L LL&  II;; Qa$(( L & r}clt|j|j|j|jdS)N)rPrOrR)rGrIrPrOrRrs rocopyzColumnProperty.copy?s- \\]]**..   r}c R|jsy|j|vrQ||j} |s| ||j<y|j|j} | j||| dy|jr/|j|vr |j ||jgdyyy)NT) no_loader)rQrrget_implr has_identity_expire_attributes) rjsession source_state source_dict dest_state dest_dictload _recursive_resolve_conflict_mapvalueimpls romergezColumnProperty.mergeGs  XX $)E&+ $((#!**4884Yt<  $ $)B  ) )DHH: * *C $r}ceZdZUdZesdZded<ded< ddZerddZ dd Z dd Z dd Z dd Z dd Z ddZy)ColumnProperty.ComparatoraProduce boolean, comparison, and other operators for :class:`.ColumnProperty` attributes. See the documentation for :class:`.PropComparator` for a brief overview. .. seealso:: :class:`.PropComparator` :class:`.ColumnOperators` :ref:`types_operators` :attr:`.TypeEngine.comparator_factory` )rrZ expressionsz*RODescriptorReference[ColumnProperty[_PT]]propSequence[NamedColumn[Any]]rc|j}||||jjd}|}|jjr,|}|jjj |}||d<|j |jd|dS)aannotate and possibly adapt a column to be returned as the mapped-attribute exposed version of the column. The column in this context needs to act as much like the column in an ORM mapped context as possible, so includes annotations to give hints to various ORM functions as to the source entity of this column. It also adapts it to the mapper's with_polymorphic selectable if one is present. )entity_namespacer parentmapper proxy_key adapt_columnorm)compile_state_pluginplugin_subject) _parententityrrr _parentmapper_polymorphic_adaptertraverse _annotate_set_propagate_attrs)rjrkperrnmapper_local_cols ro_orm_annotate_columnz.ColumnProperty.Comparator._orm_annotate_columns##B$& " "!YY]] +KC !!66#& ((==FFsK /? N+==-BB)."E r}cyrrrs rorz,ColumnProperty.Comparator.__clause_element__scr}c|jr=|j|jjd|jjS|j |jjdSrqadapterrrIrrrrs ro#_memoized_method___clause_element__z=ColumnProperty.Comparator._memoized_method___clause_element__sS||||DII$5$5a$8$))--HH001B1B11EFFr}c|j} |jS#t$r|jjcYSwxYw)z(The .info dictionary for this attribute.)rrZAttributeErrorr)rjces ro_memoized_attr_infoz-ColumnProperty.Comparator._memoized_attr_infos=((*B &ww! &yy~~% &s AAc$|jrH|jjDcgc](}|j||jj*c}S|jjDcgc]}|j |c}Scc}wcc}w)zThe full sequence of columns referenced by this attribute, adjusted for any aliasing in progress. .. versionadded:: 1.3.17 r)rjrns ro_memoized_attr_expressionsz4ColumnProperty.Comparator._memoized_attr_expressionss|| $yy000LLdiimm40 ?Cii>O>O>OsD--c2>O  s -B-B c6t|j|S)zproxy attribute access down to the mapped column. this allows user-defined comparison methods to be accessed. )rgr)rjrrs ro_fallback_getattrz+ColumnProperty.Comparator._fallback_getattrs 4224c: :r}c6||jg|i|Srrrjopotherkwargss rooperatez!ColumnProperty.Comparator.operates"d--/B%B6B Br}c V|j}||j|||fi|Srr _bind_paramrjrrrrns roreverse_operatez)ColumnProperty.Comparator.reverse_operates/))+Ccoob%0#@@ @r}N)rkrFreturnrF)rzNamedColumn[_PT])rr=)rr)rrstrrrrr@rrrrrzColumnElement[Any])__name__ __module__ __qualname____doc__r __slots____annotations__rrrrrrrrrr}rordras $CI88// & P  A G  G & " ; C" C,/ C;> C  C  A" A+. A:= A  Ar}rdc|jr |jstj|St |jj j dz|jzS)N.)rrrobject__repr__rrrrs ro__str__zColumnProperty.__str__sG{{$((??4( (4;;%%../#5@@r})rkz_ORMColumnExprArgument[_T]rlz_ORMColumnExprArgument[Any]rYzOptional[_AttributeOptions]rOrLrPrJrXrJrNz"Optional[Type[PropComparator[_T]]]rRrJrSrJrZzOptional[_InfoType]r[rLr\rJr]rJrtr8rur6rv Type[Any]rwrLrrrrxzOptional[Type[Mapped[Any]]]ryOptional[_AnnotationScanType]rzrr{rJrNonerzOptional[MapperProperty[_T]]rzList[Tuple[Column[Any], int]])rrJ)rz _InstallLoaderCallableProto[Any])rzroles.ColumnsClauseRole)rz Mapper[Any]rr)rr)rzColumnProperty[_T])rr:rInstanceState[Any]rr4rrrr4rrJrzDict[Any, object]rz#Dict[_IdentityKeyType[Any], object]rrrr)!rrrrr _COLUMN_TOKENstrategy_wildcard_key inherit_cache_links_to_entityrrr`r|propertyrrrr%preload_modulerrrrrrrr MemoizedSlotsrrErdr __classcell__)rcs@rorGrG_s-::M ###''%%00I*:>#AE$ $$(! /498*989987 98  98  9898?989898"989898)-98v)   *   62&C! $   T/1LM  )  N  T/1LM  )  N  *    )#  '  ! & C 4BAT'')<BAHAr}rGceZdZdZdZy)MappedSQLExpressionaNDeclarative front-end for the :class:`.ColumnProperty` class. Public constructor is the :func:`_orm.column_property` function. .. versionchanged:: 2.0 Added :class:`_orm.MappedSQLExpression` as a Declarative compatible subclass for :class:`_orm.ColumnProperty`. .. seealso:: :class:`.MappedColumn` TN)rrrrrrr}rorrs Mr}rcreZdZUdZdZded<ded<ded<d ed <d ed <d ed<ddZddZeddZ ed dZ ed!dZ d"dZ d#dZ d#dZd$dZ d%dZej$d d&dZ d'dZy)( MappedColumna_Maps a single :class:`_schema.Column` on a class. :class:`_orm.MappedColumn` is a specialization of the :class:`_orm.ColumnProperty` class and is oriented towards declarative configuration. To construct :class:`_orm.MappedColumn` objects, use the :func:`_orm.mapped_column` constructor function. .. versionadded:: 2.0 ) rkrT _sort_order foreign_keys _has_nullable_has_insert_defaultrPdeferred_groupdeferred_raiseloadrR_attribute_options_has_dataclass_arguments_use_existing_columnzUnion[_NoArg, bool]rPrJrrLr Column[_T]rkzOptional[Set[ForeignKey]]rrrc|jdtx|_|jdd|_duxr2tk7xr't fdt j D|_|jdtj}|tju|_ |jr||d<n+jtjurj|d<|jdd|_ |jdd|_ |jd tj|_|jd d|_|jd tj|_t#d t%|i||_|j&j(|_d |vxr#|j+d dt,j.fv|_t3j4|y)NrYuse_existing_columnFc3XK|]!\}}|dk7r|tju#yw)dataclasses_defaultN)r(NO_ARG).0iattr attr_optss ro z(MappedColumn.__init__..2s3;GAt00! FMM1;s'*insert_defaultdefaultrrrPrR sort_orderrnullable)poprrrany enumerate_fieldsrr(rrrrrrPrRrrr)rkrgetr*NULL_UNSPECIFIEDrr%rh)rjargkwr%r#s @ror`zMappedColumn.__init__(s.0ff !;/  )%'FF+@%$H! T ! 77 ():):; % 0&--@#1#F  # #*ByM  * *&-- ?%99ByM ff%5t<"$&&)=t"Dz6==9  ff%5u=66, ><););<  KK44'2- "&&2D   ( (M 3  %r}c F|jj|j}|jjdi||_|j|_|j |_|j |_|jj|_|j|_|j|_ |j|_ |j|_ |j|_ |j|_ |j|_tj ||S)Nr)rc__new__rk_copyrPrrrrRrrrrrrr%rh)rjr0news ror3zMappedColumn._copyOsnn$$T^^4&T[[&&,, }} !00!%!8!8::22!00 ..!%!8!8"&":":'+'D'D$#'#<#< ** $ r}c.|jjSr)rkrsrs rorszMappedColumn.name`s{{r}c(|j}|tjur#t|jxs |j }|s |j rCt|j||j|j |j|j Sy)N)rPrOrXrYrR) rPr(rrJrrrRrGrkr)rjeffective_deferreds rorz&MappedColumn.mapper_property_to_assignds!]]  .!%##>t'>'>"  !4!4! +))11"&"9"9#22  r}ct|j|jtjur|jfgSdfgSrq)rkrr(rrs rorzMappedColumn.columns_to_assignxsM ''v}}<$$       r}c|jSr)rkrs rorzMappedColumn.__clause_element__s {{r}c6||jg|i|Srrrs rorzMappedColumn.operates"$))+>e>v>>r}c V|j}||j|||fi|Srrrs rorzMappedColumn.reverse_operates/%%'#//"e,c#>#@#@#D#D$ FT[ :: FJ ;; FK++ & .t{{'?'?((c2 ((   '   r}zsqlalchemy.orm.decl_basectjj}|j||j|j ||||yr)r%r orm_decl_base_undefer_column_namerkrH)rjrurvrwrr param_nameparam_annotation decl_bases rodeclarative_scan_for_compositez+MappedColumn.declarative_scan_for_composites@NN00 &&z4;;? (( +-? r}c`|jj}t|ddr|Jt|||d}t |}|j s||j_t|}d}d} d} t|r%d} t|} | d} |r t| } | dd}n8t|r-t|jrt|jdd}|D]} t| ts| } nd} | ?|js'| jjd|j_| jj!|j|jj}| j"t$j&ur-|j"t$j&ur| j"|_| j(|j(| j(|_| j*|j*| j*|_| j,r|j,sd|_| j.r| j.|_| j0-|j0t$j&ur| j0|_| jj2| jj4t7j8dd | j:rst=| j>j@D]Q\}}| j>|t$j&us&|jCd d }t7j8d |d d S|jDr|jjFsd}| r|| g}n|g}|D]}|jI|}|nt|tJs t|tr@tM|tJr0tOjPd|jj2d|dtOjPd|d|jj2d|jjS|yyy)NT) check_genericcheck_for_plain_string)include_genericrFrrz_Can't use the 'key' or 'name' arguments in Annotated with mapped_column(); this will be ignoredz2.0.22 dataclasses_z Argument 'zp' is a dataclass argument and cannot be specified within a mapped_column() bundled inside of an Annotated objectzThe type provided inside the z4 attribute Mapped annotation is the SQLAlchemy type z . Expected a Python type insteadz6Could not locate SQLAlchemy Core type for Python type z inside the z attribute Mapped annotation)*rkrEr/r r.rr(r,r0r-r1 __value__rrrr&_mergerPr(rrrrrRrrrrsr%warn_deprecatedrr+rr,replacerFr _resolve_typer+ issubclassrBrC _set_type)rjrvruargumentrwrKr(our_typefind_mapped_inour_type_is_pep593raw_pep_593_typepep_593_componentselem use_args_fromidxr/ new_sqltypechecks check_types rorHz(MappedColumn._init_column_for_annotations++""  D &1 11.X14H!*!!#+DKK -h7*," X !% !)(!3 1!4 #=>N#O /3N x Yx/A/A%B%h&8&89!"=N#D$ - $ # !M  $,,!((00<&* #  ' ' 4kk&&G&&fmm;MMV]]2 - 6 6 ,,8''/&3&B&B#00<++3*7*J*J'2211,0)++&3&B&B#))5$$ 5#0#<#< $$((4 '',,8$$K 55 )!44<<!HC&88=%}}-"kk."=,,(.DD% ! ??4;;#;#;K""$45"$ &44Z@ *% h 3x."8Z8 ..7 7JKN#*$DF !.. (zdkkoo5HI66 KK ! !+ .=$r? sql.operatorsr@rArBrCrErF__all__ class_logger IdentifiedrGrrrr}ror~sm# $/7-)2/$&&+/)$%4"'$##)&/&1 2$',*,13 T e3 e-. HANN HAHAV .,.@.D$p/rp/r}