/opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/orm/__pycache__
NameSizeModeActions
attributes.cpython-311.pyc813680644editdlrm
base.cpython-311.pyc182890644editdlrm
collections.cpython-311.pyc745770644editdlrm
dependency.cpython-311.pyc439710644editdlrm
deprecated_interfaces.cpython-311.pyc231610644editdlrm
descriptor_props.cpython-311.pyc423920644editdlrm
dynamic.cpython-311.pyc209430644editdlrm
evaluator.cpython-311.pyc89160644editdlrm
events.cpython-311.pyc1172030644editdlrm
exc.cpython-311.pyc101560644editdlrm
identity.cpython-311.pyc179340644editdlrm
instrumentation.cpython-311.pyc262120644editdlrm
interfaces.cpython-311.pyc314500644editdlrm
loading.cpython-311.pyc344410644editdlrm
mapper.cpython-311.pyc1371230644editdlrm
path_registry.cpython-311.pyc207410644editdlrm
persistence.cpython-311.pyc713850644editdlrm
properties.cpython-311.pyc168780644editdlrm
query.cpython-311.pyc1905890644editdlrm
relationships.cpython-311.pyc1440070644editdlrm
scoping.cpython-311.pyc87380644editdlrm
session.cpython-311.pyc1463200644editdlrm
state.cpython-311.pyc400190644editdlrm
strategies.cpython-311.pyc980710644editdlrm
strategy_options.cpython-311.pyc664690644editdlrm
sync.cpython-311.pyc70290644editdlrm
unitofwork.cpython-311.pyc342400644editdlrm
util.cpython-311.pyc545720644editdlrm
__init__.cpython-311.pyc124930644editdlrm
Edit: /opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/orm/__pycache__/query.cpython-311.pyc (190589B)
§ cº3ûãL{ãó—dZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd l m Z dd l m Z dd l mZdd l mZddl mZddl mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlmZddl!m"Z"ddl!mZ#ddl!m$Z$dd l%m&Z&dd!l'm(Z(dd"l)m*Z*gd#¢Z+ej,Z-ej.e j/Gd$„d%e0¦«¦«¦«Z1Gd&„d'e*¦«Z2Gd(„d)e0¦«Z3Gd*„d+e3¦«Z4ej.Gd,„d-e¦«¦«Z5Gd.„d/e3¦«Z6Gd0„d1e3¦«Z7Gd2„d3e0¦«Z8Gd4„d5ej9¦«Z:d6S)7aThe Query class and support. Defines the :class:`_query.Query` class, the central construct used by the ORM to construct database queries. The :class:`_query.Query` class should not be confused with the :class:`_expression.Select` class, which defines database SELECT operations at the SQL (non-ORM) level. ``Query`` differs from ``Select`` in that it returns ORM-mapped objects and interacts with an ORM session, whereas the ``Select`` construct interacts directly with the database to return iterable result sets. é)Úchainé)Ú attributes)Úexc)Ú interfaces)Úloading)Ú persistence)Ú properties©Ú_entity_descriptor)Ú _generative)Ú_is_aliased_class)Ú_is_mapped_class©Ú _orm_columns)ÚInspectionAttr)Ú PathRegistry)Ú_entity_corresponds_to)Úaliased)Ú AliasedClass)Újoin)Ú object_mapper)Ú ORMAdapter)Ú with_parenté)Úinspect)Ú inspection)Úlog)Úsql)Úutil)Ú expression)Úvisitors)ÚColumnCollection)Ú_interpret_as_from)Ú ForUpdateArg)ÚQueryÚ QueryContextrcó¦ —eZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZe¦«ZdZdZdZdZdZdZdZdZdZdZiZ dZ!dZ"e#j$¦«xZ%Z&e#j$¦«Z'e#j$¦«Z(e#j$¦«Z)dZ*dZ+dZ,dZ-dZ.e/Z0dZ1dZ2dZ3 d�d„Z4d�d„Z5d„Z6d „Z7d „Z8d „Z9d „Z:d „Z;e<¦«d„¦«Z=e<¦«d„¦«Z>d„Z?d„Z@d„ZAd„ZBeCd„¦«ZDd„ZEd„ZFd„ZGd�d„ZHd„ZId„ZJd„ZKd�d„ZLd�d„ZMd„ZNd„ZOd „ZP d‘d!„ZQd"„ZReCd#„¦«ZSd’d$„ZTd“d%„ZUd&„ZVd'„ZWeCd(„¦«ZXd)„ZYe<¦«d*„¦«ZZeCd+„¦«Z[e<¦«d,„¦«Z\d-„Z]e<¦«d.„¦«Z^e<¦«d/„¦«Z_eCd0„¦«Z`e<¦«d1„¦«Zae„Zpe<¦«d?„¦«Zqe<¦«d@„¦«ZrdA„ZsesZtdB„Zue<¦«dC„¦«Zve<¦«dD„¦«Zwe#jxdEdFd¦«dG„¦«ZydH„ZzdI„Z{e<¦«dJ„¦«Z|dK„Z}e<¦«d•dM„¦«Z~d•dN„ZdO„Z€e<¦«dP„¦«Z�e<¦«e#j‚dQdR¦«dS„¦«¦«Zƒe<¦« d–dT„¦«Z„e<¦«dU„¦«Z…eˆ>Ý”| HÑ-Ô-ð *ð *�Ø�˜t SÑ)Ô)Ð)Ð)à × (Ò (¨¬Ñ 8Ô 8Ð 8Ð 8Ð 8ð ˆ>r2c ó¦—|j ¦«x|_}|D]­}|jD]£}||vr�t|¦«}|js_|jjrS|jj|jvr=|  |jtj |j |jj ¦«¦«d}n|jr|j}nd}||f||<|j||ŽŒ¤Œ®dS©N)Ú_mapper_adapter_mapÚcopyr/rÚis_aliased_classÚmapperÚwith_polymorphicÚpersist_selectabler,Ú"_mapper_loads_polymorphically_withÚsql_utilÚ ColumnAdapterÚ selectableÚ_equivalent_columnsÚ_adapterÚ setup_entity)r.r/Údr;ÚentityÚext_infoÚaliased_adapters r0r9zQuery._set_entity_selectablesãs€Ø'+Ô'?×'DÒ'DÑ'FÔ'FÐFˆÔ  1àð -ð -ˆCØœ,ð -ð -�Ø �?�?Ý& v™œ�Hà$Ô5ð/à$œOÔ<ð/ð %œOÔ>Ø#'Ô#=ð>ð>ð!×CÒCØ (¤Ý (Ô 6Ø$,Ô$7Ø$,¤OÔ$Gñ!"ô!"ñôðð+/˜˜Ø!Ô2ð/Ø*2Ô*;˜˜à*.˜à!)¨?Ð ;�A�f‘IØ �Ô  ! F¤)Ð,Ð,Ð,ð3 -ð -ð -r2có€—|jp|gD]2}||j|<| ¦«D]}||j|j<ŒŒ3dSr=)Ú_with_polymorphic_mappersr,Úiterate_to_rootÚ local_table)r.rAÚadapterÚm2Úms r0rDz(Query._mapper_loads_polymorphically_withsk€ØÔ2Ð>°v°hð Dð DˆBØ-4ˆDÔ & rÑ *Ø×'Ò'Ñ)Ô)ð Dð D�ØÔ>ð0Ø'Ÿ~š~Ñ/Ô/�HØ!ð1Ø(0Ð%Ø— ’ ˜(Ñ#Ô#Ð#Ð#å˜r™œˆŒð ð 1å�D”NÑ#Ô# qÒ(Ð(ÝÐ,­jÔ.>Ñ?Ô?ð)ð×&Ò&Ñ(Ô(ˆFÝ#+Ô#9Ø”˜qÔ! 6ñ$ô$ˆDÔ Ð Ð ð ð 1å�D”NÑ#Ô# qÒ(Ð(ݘ˜hÑ'Ô'ð)àÔ%ð)ð$(¤=ˆDÔ Ð Ð ð  1ð 1à(Ð(Ð(Ð(Ð(Ð(r2có¾—|jD]T}|j |d¦«| ¦«D]"}|j |jd¦«Œ#ŒUdSr=)rPr,ÚpoprQrR)r.rArTrUs r0Ú_reset_polymorphic_adapterz Query._reset_polymorphic_adapter7s|€ØÔ2ð Dð DˆBØ Ô &× *Ò *¨2¨tÑ 4Ô 4Ð 4Ø×'Ò'Ñ)Ô)ð Dð D�ØÔ*×.Ò.¨q¬}¸dÑCÔCÐCÐCð Dð Dð Dr2cóh—d|jvr?|jd}|j |d¦«}|r| |¦«St |t j¦«r|}nt|d¦«r|j}ndS|j |d¦«}|r| |¦«SdS)NÚ parententityÚtable) Ú _annotationsr,ÚgetÚ adapt_clauser^r!Ú FromClauserWrt)r.ÚelementÚsearchr`s r0Ú_adapt_polymorphic_elementz Query._adapt_polymorphic_element=sË€Ø ˜WÔ1Ð 1Ð 1ØÔ)¨.Ô9ˆFØÔ.×2Ò2°6¸4Ñ@Ô@ˆEØð 3Ø×)Ò)¨'Ñ2Ô2Ð2å �g�zÔ4Ñ 5Ô 5ð ØˆFˆFÝ �W˜gÑ &Ô &ð Ø”]ˆFˆFà�4àÔ*×.Ò.¨v°tÑ<Ô<ˆØ ð /Ø×%Ò% gÑ.Ô.Ð .ð /ð /r2có ‡—ˆfd„|D¦«S)Ncób•—g|]+}‰ tj|¦«dd¦«‘Œ,S©T)Ú _adapt_clauser!Ú_literal_as_label_reference)Ú.0Úor.s €r0ú z)Query._adapt_col_list..PsMø€ð ð ð ðð × Ò ÝÔ6°qÑ9Ô9¸4Àñ ô ð ð ð r2r))r.Úcolss` r0Ú_adapt_col_listzQuery._adapt_col_listOs0ø€ð ð ð ð ðð  ñ ô ð r2có—||_dSr=)Úlazy_loaded_from)r.Ústates r0Ú_set_lazyload_fromzQuery._set_lazyload_fromWs€à %ˆÔÐÐr2có—d|_dS©NF)Ú_orm_only_adapt©r.s r0Ú_adapt_all_clauseszQuery._adapt_all_clauses[s€à$ˆÔÐÐr2có^‡—gŠ|jsd}|r-|jr&|jD]}‰ ||jf¦«Œ|jr*‰ |jr|nd|jjf¦«|jr‰ ||jf¦«‰s|Sˆfd„}tj |i|¦«S)z\Adapt incoming clauses to transformations which have been applied within this query.Fcóf•—d|jvpd|jv}‰D]\}}|r|r||¦«}|�|cSŒdS)NÚ _orm_adaptrs©ru)ÚelemÚ is_orm_adaptÚ _orm_onlyrSÚeÚadapterss €r0Úreplacez$Query._adapt_clause..replacesnø€à Ô 1Ð1ð7Ø! TÔ%6Ð6ð ð'/ð !ð !Ñ"� ˜7Ø ð! Lð!ؘ ™ œ �AØ�}Ø ˜˜˜øð  !ð !r2) rŒÚ_filter_aliasesr\r˜rfÚ_orm_only_from_obj_aliasr,r{r"Úreplacement_traverse)r.ÚclauseÚ as_filterÚorm_onlyrir˜r—s @r0rzQuery._adapt_clause_sø€ðˆðÔ#ð ØˆHà ð 8˜Ô-ð 8ØÔ*ð 8ð 8�Ø—’ ¨2¬:Ð 6Ñ7Ô7Ð7Ð7à Ô ð ð �OŠOà $Ô =ÐH�H�HÀ5ØÔ(Ô0ðñ ô ð ð Ô %ð IØ �OŠO˜X tÔ'FÐGÑ HÔ HÐ Hàð ØˆMð !ð !ð !ð !ð !õÔ,¨V°R¸ÑAÔAÐAr2có—|jdS)zReturn the first QueryEntity.r©r5r�s r0Ú_query_entity_zerozQuery._query_entity_zeroŒs€àŒ~˜aÔ Ð r2có&—|jdjS)z8Return the Mapper associated with the first QueryEntity.r)r5rAr�s r0Ú _mapper_zerozQuery._mapper_zero�s€àŒ~˜aÔ Ô'Ð'r2cóP—|j�|jn| ¦«jS)z›Return the 'entity' (mapper or AliasedClass) associated with the first QueryEntity, or alternatively the 'select from' entity if specified.)rYr¡Ú entity_zeror�s r0Ú _entity_zerozQuery._entity_zero”s/€ðÔ'Ð3ð Ô $Ð $à×(Ò(Ñ*Ô*Ô6ð r2c#óPK—|jD]}t|t¦«r|V—ŒdSr=)r5r^Ú _MapperEntity)r.r;s r0Ú_mapper_entitieszQuery._mapper_entitiesŸs=èè€à”>ð ð ˆCݘ#�}Ñ-Ô-ð Ø� � � øð ð r2có\—|j d| ¦«¦«S)NÚ_joinpoint_entity)Ú _joinpointrvr¦r�s r0Ú_joinpoint_zerozQuery._joinpoint_zero¥s'€ØŒ×"Ò"Ð#6¸×8IÒ8IÑ8KÔ8KÑLÔLÐLr2cól—| ¦«}|�t|¦«}|js|jSdSr=)r¦rÚis_clause_elementrA)r.ÚezeroÚinsps r0Ú _bind_mapperzQuery._bind_mapper¨s<€Ø×!Ò!Ñ#Ô#ˆØ Рݘ5‘>”>ˆDØÔ)ð #Ø”{Ð"àˆtr2cój—|j|jgkrtjd|z¦«‚|jjS)Nz4%s() can only be used against a single mapped class.)r5r6rZÚInvalidRequestErrorr¥)r.Úmethnames r0Ú_only_full_mapper_zerozQuery._only_full_mapper_zero±sE€Ø Œ>˜dÔ2Ð3Ò 3Ð 3ÝÔ,ð)Ø+3ñ4ñôð ðÔ#Ô/Ð/r2có†—t|j¦«dkrtj|pd¦«‚| ¦«S)Nrz8This operation requires a Query against a single mapper.)rcr5rZr´r¦)r.Ú rationales r0Ú_only_entity_zerozQuery._only_entity_zero¹sM€Ý ˆtŒ~Ñ Ô  Ò "Ð "ÝÔ,Øð+ð+ñôð ð × Ò Ñ"Ô"Ð"r2có\—i}|jD]!}| |jj¦«Œ"|Sr=)r©ÚupdaterArH)r.rmr;s r0Ú __all_equivszQuery.__all_equivsÂs8€ØˆØÔ(ð :ð :ˆCØ �MŠM˜#œ*Ô8Ñ 9Ô 9Ð 9Ð 9؈ r2có2—| ddd¬¦«S©NrvF)Úorder_byÚdistinct)Ú_no_criterion_conditionr�s r0Ú_get_conditionzQuery._get_conditionÈs&€Ø×+Ò+Ø ˜E¨Eð,ñ ô ð r2có6—| ddd¬¦«dSr¾)Ú_no_criterion_assertionr�s r0Ú_get_existing_conditionzQuery._get_existing_conditionÍs#€Ø ×$Ò$ U°UÀUÐ$ÑKÔKÐKÐKÐKr2có—|jsdS|j€5|j€.|js'|j€ |j€|js|r|js |r|jrtj d|z¦«‚dSdS©NzÔ>Ð>àˆŒØ,0Ð0ˆŒ˜$œ/Ø;@Ð@ˆŒÐ@˜œ¨$¬.¨.¨.r2có~—|jsdS|jrtjd|z¦«‚| |¦«dSrÇ)rÈrÎrZr´rÁ©r.rÑs r0Ú_no_clauseelement_conditionz!Query._no_clauseelement_conditionésZ€ØÔ&ð Ø ˆFØ Œ>ð ÝÔ,ð2Ø48ñ9ñôð ð ×$Ò$ TÑ*Ô*Ð*Ð*Ð*r2cóT—|jsdS|j�tjd|z¦«‚dS)Nz[Query.%s() being called on a Query with an existing full statement - can't apply criterion.)rÈrÊrZr´rÔs r0Ú_no_statement_conditionzQuery._no_statement_conditionósF€ØÔ&ð Ø ˆFØ Œ?Ð &ÝÔ,ð9ðñ ñôð ð 'Ð &r2cój—|jsdS|j€|j�tjd|›d|›d�¦«‚dS)NzQuery.zž() being called on a Query which already has LIMIT or OFFSET applied. To modify the row-limited results of a Query, call from_self() first. Otherwise, call z*() before limit() or offset() are applied.)rÈrËrÌrZr´rÔs r0Ú_no_limit_offsetzQuery._no_limit_offsetÿsU€ØÔ&ð Ø ˆFØ Œ;Ð " d¤lÐ&>ÝÔ,Ð,ð #' $ $¨¨¨ð .ñôð ð'?Ð&>r2cóz—|r||_|r||_|r||_|rt|¦«|_|r||_|Sr=)Ú_populate_existingÚ_version_checkÚ_refresh_stateÚsetÚ_only_load_propsÚ_refresh_identity_token)r.Úpopulate_existingÚ version_checkÚonly_load_propsÚ refresh_stateÚidentity_tokens r0Ú _get_optionszQuery._get_options sa€ð ð 8Ø&7ˆDÔ #Ø ð 0Ø"/ˆDÔ Ø ð 0Ø"/ˆDÔ Ø ð 9Ý$'¨Ñ$8Ô$8ˆDÔ !Ø ð :Ø+9ˆDÔ (؈ r2cóz—|j}| |¦«}|j ¦«|_|Sr=©Ú __class__Ú__new__Ú__dict__r?)r.ÚclsÚqs r0Ú_clonez Query._clones4€ØŒnˆØ �KŠK˜Ñ Ô ˆØ”]×'Ò'Ñ)Ô)ˆŒ ؈r2cóˆ—| |j¬¦«j}|jr| |j¦«}|S)z×The full SELECT statement represented by this Query. The statement by default will not have disambiguating labels applied to the construct unless with_labels(True) is called first. )Úlabels)Ú_compile_contextÚ _with_labelsÚ statementÚ_paramsÚparams)r.Ústmts r0rózQuery.statement%sB€ð×$Ò$¨DÔ,=Ð$Ñ>Ô>ÔHˆØ Œ<ð -Ø—;’;˜tœ|Ñ,Ô,ˆDàˆ r2có¾—| d¦«}|r| ¦«}|j}|r| ¦«}| |¬¦«S)a–Return the full SELECT statement represented by this :class:`_query.Query`, embedded within an :class:`_expression.Alias`. Eager JOIN generation within the query is disabled. :param name: string name to be assigned as the alias; this is passed through to :meth:`_expression.FromClause.alias`. If ``None``, a name will be deterministically generated at compile time. :param with_labels: if True, :meth:`.with_labels` will be called on the :class:`_query.Query` first to apply table-qualified labels to all columns. :param reduce_columns: if True, :meth:`_expression.Select.reduce_columns` will be called on the resulting :func:`_expression.select` construct, to remove same-named columns where one also refers to the other via foreign key or WHERE clause equivalence. F)Úname)Úenable_eagerloadsÚ with_labelsróÚreduce_columnsr`)r.rørúrûrís r0ÚsubqueryzQuery.subquery5s`€ð. × "Ò " 5Ñ )Ô )ˆØ ð Ø— ’ ‘”ˆAØ ŒKˆà ð #Ø× Ò Ñ"Ô"ˆAØ�wŠw˜DˆwÑ!Ô!Ð!r2có`—| d¦«j ||¬¦«S)aFReturn the full SELECT statement represented by this :class:`_query.Query` represented as a common table expression (CTE). Parameters and usage are the same as those of the :meth:`_expression.SelectBase.cte` method; see that method for further details. Here is the `PostgreSQL WITH RECURSIVE example `_. Note that, in this example, the ``included_parts`` cte and the ``incl_alias`` alias of it are Core selectables, which means the columns are accessed via the ``.c.`` attribute. The ``parts_alias`` object is an :func:`_orm.aliased` instance of the ``Part`` entity, so column-mapped attributes are available directly:: from sqlalchemy.orm import aliased class Part(Base): __tablename__ = 'part' part = Column(String, primary_key=True) sub_part = Column(String, primary_key=True) quantity = Column(Integer) included_parts = session.query( Part.sub_part, Part.part, Part.quantity).\ filter(Part.part=="our part").\ cte(name="included_parts", recursive=True) incl_alias = aliased(included_parts, name="pr") parts_alias = aliased(Part, name="p") included_parts = included_parts.union_all( session.query( parts_alias.sub_part, parts_alias.part, parts_alias.quantity).\ filter(parts_alias.part==incl_alias.c.sub_part) ) q = session.query( included_parts.c.sub_part, func.sum(included_parts.c.quantity). label('total_quantity') ).\ group_by(included_parts.c.sub_part) .. seealso:: :meth:`_expression.HasCTE.cte` F)røÚ recursive)rùróÚcte)r.rørþs r0rÿz Query.cteUs8€ðn×%Ò% eÑ,Ô,Ô6×:Ò:Ø ð;ñ ô ð r2có\—| d¦«j |¦«S)zàReturn the full SELECT statement represented by this :class:`_query.Query`, converted to a scalar subquery with a label of the given name. Analogous to :meth:`_expression.SelectBase.label`. F)rùróÚlabel)r.røs r0rz Query.label�s)€ð×%Ò% eÑ,Ô,Ô6×<Ò<¸TÑBÔBÐBr2cóZ—| d¦«j ¦«S)z½Return the full SELECT statement represented by this :class:`_query.Query`, converted to a scalar subquery. Analogous to :meth:`_expression.SelectBase.as_scalar`. F)rùróÚ as_scalarr�s r0rzQuery.as_scalar›s'€ð×%Ò% eÑ,Ô,Ô6×@Ò@ÑBÔBÐBr2có*—| ¦«S)z÷Return the :class:`_expression.Select` object emitted by this :class:`_query.Query`. Used for :func:`_sa.inspect` compatibility, this is equivalent to:: query.enable_eagerloads(False).with_labels().statement )Ú__clause_element__r�s r0rGzQuery.selectable¥s€ð×&Ò&Ñ(Ô(Ð(r2cóZ—| d¦« ¦«jSr‹)rùrúrór�s r0rzQuery.__clause_element__±s%€Ø×%Ò% eÑ,Ô,×8Ò8Ñ:Ô:ÔDÐDr2có—||_dS)zÿWhen set to True, the query results will always be a tuple. This is specifically for single element queries. The default is False. .. versionadded:: 1.2.5 .. seealso:: :meth:`_query.Query.is_single_entity` N)Ú_only_return_tuples©r.Úvalues r0Úonly_return_tupleszQuery.only_return_tuples´s€ð$)ˆÔ Ð Ð r2cóf—|j o)t|j¦«dko|jdjS)a€Indicates if this :class:`_query.Query` returns tuples or single entities. Returns True if this query returns a single entity for each instance in its result list, and False if this query returns a tuple of entities for each result. .. versionadded:: 1.3.11 .. seealso:: :meth:`_query.Query.only_return_tuples` rr)rrcr5Úsupports_single_entityr�s r0Úis_single_entityzQuery.is_single_entityÃs;€ð"Ô(Ð (ð 9Ý�D”NÑ#Ô# qÒ(ð 9à”˜qÔ!Ô8ð r2có—||_dS)aControl whether or not eager joins and subqueries are rendered. When set to False, the returned Query will not render eager joins regardless of :func:`~sqlalchemy.orm.joinedload`, :func:`~sqlalchemy.orm.subqueryload` options or mapper-level ``lazy='joined'``/``lazy='subquery'`` configurations. This is used primarily when nesting the Query's statement into a subquery or other selectable, or when using :meth:`_query.Query.yield_per`. N)Ú_enable_eagerloadsr s r0rùzQuery.enable_eagerloadsÙs€ð #(ˆÔÐÐr2có0—tjd|z¦«‚)Nz¹The yield_per Query option is currently not compatible with %s eager loading. Please specify lazyload('*') or query.enable_eagerloads(False) in order to proceed with query.yield_per().)rZr´)r.Úmessages r0Ú _no_yield_perzQuery._no_yield_perës&€ÝÔ(ð .ð18ñ  8ñ ô ð r2có—d|_dS)aíApply column labels to the return value of Query.statement. Indicates that this Query's `statement` accessor should return a SELECT statement that applies labels to all columns in the form _; this is commonly used to disambiguate columns from multiple tables which have the same name. When the `Query` actually issues SQL to load rows, it always uses column labeling. .. note:: The :meth:`_query.Query.with_labels` method *only* applies the output of :attr:`_query.Query.statement`, and *not* to any of the result-row invoking systems of :class:`_query.Query` itself, e.g. :meth:`_query.Query.first`, :meth:`_query.Query.all`, etc. To execute a query using :meth:`_query.Query.with_labels`, invoke the :attr:`_query.Query.statement` using :meth:`.Session.execute`:: result = session.execute(query.with_labels().statement) TN)ròr�s r0rúzQuery.with_labelsôs€ð2!ˆÔÐÐr2có—||_dS)aControl whether assertions are generated. When set to False, the returned Query will not assert its state before certain operations, including that LIMIT/OFFSET has not been applied when filter() is called, no criterion exists when get() is called, and no "from_statement()" exists when filter()/order_by()/group_by() etc. is called. This more permissive mode is used by custom Query subclasses to specify criterion or other modifiers outside of the usual usage patterns. Care should be taken to ensure that the usage pattern is even possible. A statement applied by from_statement() will override any criterion set by filter() or order_by(), for example. N)rÈr s r0Úenable_assertionszQuery.enable_assertionss€ð(#(ˆÔÐÐr2có—|jS)zÖA readonly attribute which returns the current WHERE criterion for this Query. This returned value is a SQL expression construct, or ``None`` if no criterion has been established. )rÉr�s r0Ú whereclausezQuery.whereclause%s €ðŒÐr2có—||_dS)aIndicate that this query applies to objects loaded within a certain path. Used by deferred loaders (see strategies.py) which transfer query options from an originating query to a newly generated query intended for the deferred load. N)Ú _current_path)r.Úpaths r0Ú_with_current_pathzQuery._with_current_path0s€ð"ˆÔÐÐr2cóÜ—|jstjd¦«‚|jd ¦«}|g|jdd…z|_| ||||¬¦«dS)aùLoad columns for inheriting classes. :meth:`_query.Query.with_polymorphic` applies transformations to the "main" mapped class represented by this :class:`_query.Query`. The "main" mapped class here means the :class:`_query.Query` object's first argument is a full class, i.e. ``session.query(SomeClass)``. These transformations allow additional tables to be present in the FROM clause so that columns for a joined-inheritance subclass are available in the query, both for the purposes of load-time efficiency as well as the ability to use these columns at query time. See the documentation section :ref:`with_polymorphic` for details on how this method is used. z(No primary mapper set up for this Query.rrN)rGÚpolymorphic_on)r6rZr´r5rîÚset_with_polymorphic)r.Úcls_or_mappersrGrrLs r0rBzQuery.with_polymorphic<s�€ð*Ô#ð ÝÔ,Ø:ñôð ð” Ô"×)Ò)Ñ+Ô+ˆØ ˜ D¤N°1°2°2Ô$6Ñ6ˆŒØ×#Ò#Ø Ø Ø!Ø)ð $ñ ô ð ð ð r2cóX—||_|j d|dœ¦«|_dS)aà Yield only ``count`` rows at a time. The purpose of this method is when fetching very large result sets (> 10K rows), to batch results in sub-collections and yield them out partially, so that the Python interpreter doesn't need to declare very large areas of memory which is both time consuming and leads to excessive memory use. The performance from fetching hundreds of thousands of rows can often double when a suitable yield-per setting (e.g. approximately 1000) is used, even with DBAPIs that buffer rows (which are most). The :meth:`_query.Query.yield_per` method **is not compatible subqueryload eager loading or joinedload eager loading when using collections**. It is potentially compatible with "select in" eager loading, **provided the database driver supports multiple, independent cursors** (pysqlite and psycopg2 are known to work, MySQL and SQL Server ODBC drivers do not). Therefore in some cases, it may be helpful to disable eager loads, either unconditionally with :meth:`_query.Query.enable_eagerloads`:: q = sess.query(Object).yield_per(100).enable_eagerloads(False) Or more selectively using :func:`.lazyload`; such as with an asterisk to specify the default loader scheme:: q = sess.query(Object).yield_per(100).\ options(lazyload('*'), joinedload(Object.some_related)) .. warning:: Use this method with caution; if the same instance is present in more than one batch of rows, end-user changes to attributes will be overwritten. In particular, it's usually impossible to use this setting with eagerly loaded collections (i.e. any lazy='joined' or 'subquery') since those collections will be cleared for a new load when encountered in a subsequent result batch. In the case of 'subquery' loading, the full result for all rows is fetched which generally defeats the purpose of :meth:`~sqlalchemy.orm.query.Query.yield_per`. Also note that while :meth:`~sqlalchemy.orm.query.Query.yield_per` will set the ``stream_results`` execution option to True, currently this is only understood by :mod:`~sqlalchemy.dialects.postgresql.psycopg2`, :mod:`~sqlalchemy.dialects.mysql.mysqldb` and :mod:`~sqlalchemy.dialects.mysql.pymysql` dialects which will stream results using server side cursors instead of pre-buffer all rows for this query. Other DBAPIs **pre-buffer all rows** before making them available. The memory use of raw database rows is much less than that of an ORM-mapped object, but should still be taken into consideration when benchmarking. .. seealso:: :meth:`_query.Query.enable_eagerloads` T)Ústream_resultsÚmax_row_bufferN)Ú _yield_perÚ_execution_optionsÚunion)r.Úcounts r0Ú yield_perzQuery.yield_per^s8€ðB ˆŒØ"&Ô"9×"?Ò"?Ø#°uÐ =Ð =ñ# ô# ˆÔÐÐr2cóB—| |tj¦«S)aaReturn an instance based on the given primary key identifier, or ``None`` if not found. E.g.:: my_user = session.query(User).get(5) some_object = session.query(VersionedFoo).get((5, 10)) some_object = session.query(VersionedFoo).get( {"id": 5, "version_id": 10}) :meth:`_query.Query.get` is special in that it provides direct access to the identity map of the owning :class:`.Session`. If the given primary key identifier is present in the local identity map, the object is returned directly from this collection and no SQL is emitted, unless the object has been marked fully expired. If not present, a SELECT is performed in order to locate the object. :meth:`_query.Query.get` also will perform a check if the object is present in the identity map and marked as expired - a SELECT is emitted to refresh the object as well as to ensure that the row is still present. If not, :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised. :meth:`_query.Query.get` is only used to return a single mapped instance, not multiple instances or individual column constructs, and strictly on a single primary key value. The originating :class:`_query.Query` must be constructed in this way, i.e. against a single mapped entity, with no additional filtering criterion. Loading options via :meth:`_query.Query.options` may be applied however, and will be used if the object is not yet locally present. A lazy-loading, many-to-one attribute configured by :func:`_orm.relationship`, using a simple foreign-key-to-primary-key criterion, will also use an operation equivalent to :meth:`_query.Query.get` in order to retrieve the target value from the local identity map before querying the database. See :doc:`/orm/loading_relationships` for further details on relationship loading. :param ident: A scalar, tuple, or dictionary representing the primary key. For a composite (e.g. multiple column) primary key, a tuple or dictionary should be passed. For a single-column primary key, the scalar calling form is typically the most expedient. If the primary key of a row is the value "5", the call looks like:: my_object = query.get(5) The tuple form contains primary key values typically in the order in which they correspond to the mapped :class:`_schema.Table` object's primary key columns, or if the :paramref:`_orm.Mapper.primary_key` configuration parameter were used, in the order used for that parameter. For example, if the primary key of a row is represented by the integer digits "5, 10" the call would look like:: my_object = query.get((5, 10)) The dictionary form should include as keys the mapped attribute names corresponding to each element of the primary key. If the mapped class has the attributes ``id``, ``version_id`` as the attributes which store the object's primary key value, the call would look like:: my_object = query.get({"id": 5, "version_id": 10}) .. versionadded:: 1.3 the :meth:`_query.Query.get` method now optionally accepts a dictionary of attribute names to values in order to indicate a primary key identifier. :return: The object instance, or ``None``. )Ú _get_implrÚload_on_pk_identity)r.Úidents r0rvz Query.get¤s€ðl�~Š~˜e¥WÔ%@ÑAÔAÐAr2cóh—| ||¬¦«}tj|j|||¦«S)aqLocate an object in the identity map. Given a primary key identity, constructs an identity key and then looks in the session's identity map. If present, the object may be run through unexpiration rules (e.g. load unloaded attributes, check if was deleted). For performance reasons, while the :class:`_query.Query` must be instantiated, it may be instantiated with no entities, and the mapper is passed:: obj = session.query()._identity_lookup(inspect(SomeClass), (1, )) :param mapper: mapper in use :param primary_key_identity: the primary key we are searching for, as a tuple. :param identity_token: identity token that should be used to create the identity key. Used as is, however overriding subclasses can repurpose this in order to interpret the value in a special way, such as if None then look among multiple target tokens. :param passive: passive load flag passed to :func:`.loading.get_from_identity`, which impacts the behavior if the object is found; the object may be validated and/or unexpired if the flag allows for SQL to be emitted. :param lazy_loaded_from: an :class:`.InstanceState` that is specifically asking for this identity as a related identity. Used for sharding schemes where there is a correspondence between an object and a related object being lazy-loaded (or otherwise relationship-loaded). .. versionadded:: 1.2.9 :return: None if the object is not found in the identity map, *or* if the object was unexpired and found to have been deleted. if passive flags disallow SQL and the object is expired, returns PASSIVE_NO_RESULT. In all other cases the instance is returned. .. versionadded:: 1.2.7 ©rå)Úidentity_key_from_primary_keyrÚget_from_identityr+)r.rAÚprimary_key_identityråÚpassiver‡Úkeys r0Ú_identity_lookupzQuery._identity_lookupüs?€ðb×2Ò2Ø °ð3ñ ô ˆõÔ(¨¬°v¸sÀGÑLÔLÐLr2c ó–‡—t‰d¦«r‰ ¦«Š| d¦«}t‰t¦«}|st j‰d¬¦«Št‰¦«t|j¦«kr9tj dd  d„|jD¦«¦«z¦«‚|r† tˆfd„|j D¦«¦«Šnd#t$rW}t jtj d d  d „|j D¦«¦«z¦«|¬ ¦«Yd}~nd}~wwxYw|jsj|jsc|j€\| |‰|¬ ¦«}|�2| ¦«t+|j|j¦«sdS|S|t0jurdS||‰¦«S) NÚ__composite_values__rvr=)ÚdefaultzmIncorrect number of values in identifier to formulate primary key for query.get(); primary key columns are %sú,c3ó K—|] }d|zV—Œ dS©z'%s'Nr)©r�Úcs r0ú z"Query._get_impl..Cs&èè€ÐBÐB¨!˜6 A™:ÐBÐBÐBÐBÐBÐBr2c3ó2•K—|]}‰|jV—ŒdSr=©r3)r�Úpropr1s €r0r=z"Query._get_impl..Hs>øèè€ð,ð,àð)¨¬Ô2ð,ð,ð,ð,ð,ð,r2ztIncorrect names of values in identifier to formulate primary key for query.get(); primary key attribute names are %sc3ó*K—|]}d|jzV—ŒdSr:r?)r�r@s r0r=z"Query._get_impl..Ss=èè€ð#ð#à $ð# T¤XÑ-ð#ð#ð#ð#ð#ð#r2©Úreplace_contextr.)rWr6r¶r^Údictr r8rcÚ primary_keyrZr´rÚlistÚ_identity_key_propsÚKeyErrorÚraise_rÛÚalways_refreshÚ_for_update_argr4rÅÚ issubclassréÚclass_rÚPASSIVE_CLASS_MISMATCH)r.r1Ú db_load_fnrårAÚis_dictÚerrÚinstances ` r0r*zQuery._get_impl2smø€å Ð'Ð)?Ñ @Ô @ð OØ#7×#LÒ#LÑ#NÔ#NÐ à×,Ò,¨UÑ3Ô3ˆåÐ1µ4Ñ8Ô8ˆØð Ý#'¤<Ø$¨gð$ñ$ô$Ð õ Ð#Ñ $Ô $­¨FÔ,>Ñ(?Ô(?Ò ?Ð ?ÝÔ,ðJà—(’(ÐBÐB¨vÔ/AÐBÑBÔBÑBÔBñCñôð ð ð ð Ý'+ð,ð,ð,ð,à &Ô :ð,ñ,ô,ñ(ô(Ð$Ð$øõ ð ð ð Ý” ÝÔ.ð'ðŸ(š(ð#ð#à(.Ô(Bð#ñ#ô#ñôññôð%(ð ñ ô ð ð ð ð ð ð øøøøð øøøðÔ'ð àÔ)ð ðÔ$Ð,ð×,Ò,ØÐ,¸^ð-ñôˆHðÐ#Ø×,Ò,Ñ.Ô.Ð.õ" (Ô"4°f´mÑDÔDð Ø˜4Ø�Ø�ZÔ>Ð>Ð>Ø�tàˆz˜$Ð 4Ñ5Ô5Ð5sà C*Ã* E Ã4A EÅE cóÒ—|D]c}|€!|j dg¦«|_Œ%|j tjt |¦«¦«¦«|_ŒddS)a@Return a :class:`.Query` construct which will correlate the given FROM clauses to that of an enclosing :class:`.Query` or :func:`~.expression.select`. The method here accepts mapped classes, :func:`.aliased` constructs, and :func:`.mapper` constructs as arguments, which are resolved into expression constructs, in addition to appropriate expression constructs. The correlation arguments are ultimately passed to :meth:`_expression.Select.correlate` after coercion to expression constructs. The correlation arguments take effect in such cases as when :meth:`_query.Query.from_self` is used, or when a subquery as returned by :meth:`_query.Query.subquery` is embedded in another :func:`_expression.select` construct. N)Ú _correlater&rEÚsurface_selectablesr$)r.ÚargsÚss r0Ú correlatezQuery.correlateqso€ð,ð ð ˆA؈yØ"&¤/×"7Ò"7¸¸Ñ"?Ô"?�”�à"&¤/×"7Ò"7ÝÔ0Õ1CÀAÑ1FÔ1FÑGÔGñ#ô#�”�ð  ð r2có—||_dS)a%Return a Query with a specific 'autoflush' setting. Note that a Session with autoflush=False will not autoflush, even if this flag is set to True at the Query level. Therefore this flag is usually used only to disable autoflush for a specific Query. N)Ú _autoflush)r.Úsettings r0Ú autoflushzQuery.autoflush�s€ð"ˆŒˆˆr2có—d|_dS)ajReturn a :class:`_query.Query` that will expire and refresh all instances as they are loaded, or reused from the current :class:`.Session`. :meth:`.populate_existing` does not improve behavior when the ORM is used normally - the :class:`.Session` object's usual behavior of maintaining a transaction and expiring all attributes after rollback or commit handles object state automatically. This method is not intended for general use. .. seealso:: :ref:`session_expire` - in the ORM :class:`_orm.Session` documentation TN)rÛr�s r0rázQuery.populate_existing›s€ð$#'ˆÔÐÐr2có—||_dS)zêSet the 'invoke all eagers' flag which causes joined- and subquery loaders to traverse into already-loaded related objects and collections. Default is that of :attr:`_query.Query._invoke_all_eagers`. N)Ú_invoke_all_eagersr s r0Ú_with_invoke_all_eagerszQuery._with_invoke_all_eagers¯s€ð#(ˆÔÐÐr2có–—|rt|¦«}n| ¦«}|€yt|¦«}|jD].}t |t j¦«r|j|jur|}n5Œ/tj d|jj j ›d|j j ›d�¦«‚|  t|||j¦«¦«S)a4Add filtering criterion that relates the given instance to a child object or collection, using its attribute state as well as an established :func:`_orm.relationship()` configuration. The method uses the :func:`.with_parent` function to generate the clause, the result of which is passed to :meth:`_query.Query.filter`. Parameters are the same as :func:`.with_parent`, with the exception that the given property can be None, in which case a search is performed against this :class:`_query.Query` object's target mapper. :param instance: An instance which has some :func:`_orm.relationship`. :param property: String property name, or class-bound attribute, which indicates what relationship from the instance should be used to reconcile the parent/child relationship. :param from_entity: Entity in which to consider as the left side. This defaults to the "zero" entity of the :class:`_query.Query` itself. Nz>Could not locate a property which relates instances of class 'z' to instances of class 'ú')rr¦rÚiterate_propertiesr^r ÚRelationshipPropertyrArZr´rMÚ__name__réÚfilterrrL)r.rRÚpropertyÚ from_entityr¥rAr@s r0rzQuery.with_parentºsä€ð8 ð .Ý! +Ñ.Ô.ˆKˆKà×+Ò+Ñ-Ô-ˆKØ Ð å" 8Ñ,Ô,ˆFàÔ1ð ð �å˜t¥ZÔ%DÑEÔEðàœ  {Ô'9Ð9Ð9à#�HØ�EøåÔ0Ð0ð$Ô*Ô1Ô:Ð:Ð:Ø Ô*Ô3Ð3Ð3ð ñôðð�{Š{�; x°¸;Ô;MÑNÔNÑOÔOÐOr2có¨—|�t||¦«}t|j¦«|_t||¦«}| |g¦«dS)zIadd a mapped entity to the list of result columns to be returned.N)rrFr5r¨r9)r.rLr`rUs r0Ú add_entityzQuery.add_entityñsU€ð РݘV UÑ+Ô+ˆFå˜dœnÑ-Ô-ˆŒÝ ˜$ Ñ 'Ô 'ˆØ ×$Ò$ a SÑ)Ô)Ð)Ð)Ð)r2có—||_dS)aReturn a :class:`_query.Query` that will use the given :class:`.Session`. While the :class:`_query.Query` object is normally instantiated using the :meth:`.Session.query` method, it is legal to build the :class:`_query.Query` directly without necessarily using a :class:`.Session`. Such a :class:`_query.Query` object, or any :class:`_query.Query` already associated with a different :class:`.Session`, can produce a new :class:`_query.Query` object associated with a target session using this method:: from sqlalchemy.orm import Query query = Query([MyClass]).filter(MyClass.id == 5) result = query.with_session(my_session).one() N)r+)r.r+s r0Ú with_sessionzQuery.with_sessionýs€ð0ˆŒ ˆ ˆ r2có—| ¦« d¦«j d¦«}| |¦«}d|_| ¦«|_|r| |¦«|S)aSreturn a Query that selects from this Query's SELECT statement. :meth:`_query.Query.from_self` essentially turns the SELECT statement into a SELECT of itself. Given a query such as:: q = session.query(User).filter(User.name.like('e%')) Given the :meth:`_query.Query.from_self` version:: q = session.query(User).filter(User.name.like('e%')).from_self() This query renders as: .. sourcecode:: sql SELECT anon_1.user_id AS anon_1_user_id, anon_1.user_name AS anon_1_user_name FROM (SELECT "user".id AS user_id, "user".name AS user_name FROM "user" WHERE "user".name LIKE :name_1) AS anon_1 There are lots of cases where :meth:`_query.Query.from_self` may be useful. A simple one is where above, we may want to apply a row LIMIT to the set of user objects we query against, and then apply additional joins against that row-limited set:: q = session.query(User).filter(User.name.like('e%')).\ limit(5).from_self().\ join(User.addresses).filter(Address.email.like('q%')) The above query joins to the ``Address`` entity but only against the first five results of the ``User`` query: .. sourcecode:: sql SELECT anon_1.user_id AS anon_1_user_id, anon_1.user_name AS anon_1_user_name FROM (SELECT "user".id AS user_id, "user".name AS user_name FROM "user" WHERE "user".name LIKE :name_1 LIMIT :param_1) AS anon_1 JOIN address ON anon_1.user_id = address.user_id WHERE address.email LIKE :email_1 **Automatic Aliasing** Another key behavior of :meth:`_query.Query.from_self` is that it applies **automatic aliasing** to the entities inside the subquery, when they are referenced on the outside. Above, if we continue to refer to the ``User`` entity without any additional aliasing applied to it, those references wil be in terms of the subquery:: q = session.query(User).filter(User.name.like('e%')).\ limit(5).from_self().\ join(User.addresses).filter(Address.email.like('q%')).\ order_by(User.name) The ORDER BY against ``User.name`` is aliased to be in terms of the inner subquery: .. sourcecode:: sql SELECT anon_1.user_id AS anon_1_user_id, anon_1.user_name AS anon_1_user_name FROM (SELECT "user".id AS user_id, "user".name AS user_name FROM "user" WHERE "user".name LIKE :name_1 LIMIT :param_1) AS anon_1 JOIN address ON anon_1.user_id = address.user_id WHERE address.email LIKE :email_1 ORDER BY anon_1.user_name The automatic aliasing feature only works in a **limited** way, for simple filters and orderings. More ambitious constructions such as referring to the entity in joins should prefer to use explicit subquery objects, typically making use of the :meth:`_query.Query.subquery` method to produce an explicit subquery object. Always test the structure of queries by viewing the SQL to ensure a particular structure does what's expected! **Changing the Entities** :meth:`_query.Query.from_self` also includes the ability to modify what columns are being queried. In our example, we want ``User.id`` to be queried by the inner query, so that we can join to the ``Address`` entity on the outside, but we only wanted the outer query to return the ``Address.email`` column:: q = session.query(User).filter(User.name.like('e%')).\ limit(5).from_self(Address.email).\ join(User.addresses).filter(Address.email.like('q%')) yielding: .. sourcecode:: sql SELECT address.email AS address_email FROM (SELECT "user".id AS user_id, "user".name AS user_name FROM "user" WHERE "user".name LIKE :name_1 LIMIT :param_1) AS anon_1 JOIN address ON anon_1.user_id = address.user_id WHERE address.email LIKE :email_1 **Looking out for Inner / Outer Columns** Keep in mind that when referring to columns that originate from inside the subquery, we need to ensure they are present in the columns clause of the subquery itself; this is an ordinary aspect of SQL. For example, if we wanted to load from a joined entity inside the subquery using :func:`.contains_eager`, we need to add those columns. Below illustrates a join of ``Address`` to ``User``, then a subquery, and then we'd like :func:`.contains_eager` to access the ``User`` columns:: q = session.query(Address).join(Address.user).\ filter(User.name.like('e%')) q = q.add_entity(User).from_self().\ options(contains_eager(Address.user)) We use :meth:`_query.Query.add_entity` above **before** we call :meth:`_query.Query.from_self` so that the ``User`` columns are present in the inner subquery, so that they are available to the :func:`.contains_eager` modifier we are using on the outside, producing: .. sourcecode:: sql SELECT anon_1.address_id AS anon_1_address_id, anon_1.address_email AS anon_1_address_email, anon_1.address_user_id AS anon_1_address_user_id, anon_1.user_id AS anon_1_user_id, anon_1.user_name AS anon_1_user_name FROM ( SELECT address.id AS address_id, address.email AS address_email, address.user_id AS address_user_id, "user".id AS user_id, "user".name AS user_name FROM address JOIN "user" ON "user".id = address.user_id WHERE "user".name LIKE :name_1) AS anon_1 If we didn't call ``add_entity(User)``, but still asked :func:`.contains_eager` to load the ``User`` entity, it would be forced to add the table on the outside without the correct join criteria - note the ``anon1, "user"`` phrase at the end: .. sourcecode:: sql -- incorrect query SELECT anon_1.address_id AS anon_1_address_id, anon_1.address_email AS anon_1_address_email, anon_1.address_user_id AS anon_1_address_user_id, "user".id AS user_id, "user".name AS user_name FROM ( SELECT address.id AS address_id, address.email AS address_email, address.user_id AS address_user_id FROM address JOIN "user" ON "user".id = address.user_id WHERE "user".name LIKE :name_1) AS anon_1, "user" :param \*entities: optional list of entities which will replace those being selected. FN) rúrùrórXÚ_from_selectableÚ_enable_single_critr¦rYr-)r.r/Ú fromclauserís r0Ú from_selfzQuery.from_selfs„€ð` × Ò Ñ Ô ß Ò ˜uÑ %Ô %Ü —y’y ‘”ð ð × !Ò ! *Ñ -Ô -ˆØ %ˆÔØ $× 1Ò 1Ñ 3Ô 3ˆÔØ ð &Ø �OŠO˜HÑ %Ô %Ð %؈r2có—||_dSr=)ro)r.Úvals r0Ú_set_enable_single_critzQuery._set_enable_single_critÒs€à#&ˆÔ Ð Ð r2cóê—dD]}|j |d¦«Œ| |gd¦«d|_|j}g|_|D]#}| ||jd¦«Œ$dS)N) rÊrÉrÎrÍrËrÌÚ _joinpathr¬rÏÚ_havingÚ _prefixesÚ _suffixesTFr)rërprnršr5Úadapt_to_selectablerb)r.rpÚattrÚ old_entitiesr–s r0rnzQuery._from_selectableÖs™€ð  ð *ð *ˆDð ŒM× Ò ˜d DÑ )Ô )Ð )Ð )Ø ×Ò˜z˜l¨DÑ1Ô1Ð1ð).ˆÔ%à”~ˆ ؈ŒØð ;ð ;ˆAØ × !Ò ! $¨¬°qÔ(9Ñ :Ô :Ð :Ð :ð ;ð ;r2có¾—|std¦«S| ¦«}| |t¬¦«|jsd|_t|¦«S)zgReturn an iterator yielding result tuples corresponding to the given list of columns. r))r:é )Úiterrîr-Ú _ColumnEntityr$)r.Úcolumnsrís r0Úvaluesz Query.valuesòsV€ð ð ݘ‘8”8ˆOØ �KŠK‰MŒMˆØ �Š˜µ ˆÑ>Ô>Ð>ØŒ|ð ØˆAŒLÝ�A‰wŒwˆr2cóv— t| |¦«¦«dS#t$rYdSwxYw)zVReturn a scalar result corresponding to the given column expression. rN)Únextr‚Ú StopIteration©r.Úcolumns r0r z Query.valuesH€ð  ݘŸ š  FÑ+Ô+Ñ,Ô,¨QÔ/Ð /øÝð ð ð Ø�4�4ð øøøs ‚'*ª 8·8có0—| |¦«dS)a7Return a new :class:`_query.Query` replacing the SELECT list with the given entities. e.g.:: # Users, filtered on some arbitrary criterion # and then ordered by related email address q = session.query(User).\ join(User.address).\ filter(User.name.like('%ed%')).\ order_by(Address.email) # given *only* User.id==5, Address.email, and 'q', what # would the *next* User in the result be ? subq = q.with_entities(Address.email).\ order_by(None).\ filter(User.id==5).\ subquery() q = q.join((subq, subq.c.email < Address.email)).\ limit(1) N)r-)r.r/s r0Ú with_entitieszQuery.with_entities s€ð2 ×Ò˜8Ñ$Ô$Ð$Ð$Ð$r2cóΗt|j¦«|_t|j¦«}|D]}t||¦«Œ| |j|d…¦«dS)zXAdd one or more column expressions to the list of result columns to be returned.N)rFr5rcr€r9)r.r‡Úlr<s r0Ú add_columnszQuery.add_columns'sm€õ ˜dœnÑ-Ô-ˆŒÝ �”Ñ Ô ˆØð #ð #ˆAÝ ˜$ Ñ "Ô "Ð "Ð "ð ×$Ò$ T¤^°A°B°BÔ%7Ñ8Ô8Ð8Ð8Ð8r2z0.7z9:meth:`.add_column` is superseded by :meth:`.add_columns`có,—| |¦«S)z½Add a column expression to the list of result columns to be returned. Pending deprecation: :meth:`.add_column` will be superseded by :meth:`.add_columns`. )rŒr†s r0Ú add_columnzQuery.add_column4s€ð×Ò Ñ'Ô'Ð'r2có—|jdg|¢RŽS)aLReturn a new :class:`_query.Query` object, applying the given list of mapper options. Most supplied options regard changing how column- and relationship-mapped attributes are loaded. .. seealso:: :ref:`deferred_options` :ref:`relationship_loader_options` F©Ú_options©r.rVs r0Úoptionsz Query.optionsCs€ð ˆtŒ}˜UÐ* TÐ*Ð*Ð*Ð*r2có—|jdg|¢RŽS©NTr�r’s r0Ú_conditional_optionszQuery._conditional_optionsUs€ØˆtŒ}˜TÐ) DÐ)Ð)Ð)Ð)r2cóP—|j ¦«|_d|jvrt¦«|jd<tt j|¦«¦«}|j|z|_|r|D]}| |¦«ŒdS|D]}| |¦«ŒdS)NÚ_unbound_load_dedupes) Ú _attributesr?rÞrar Úflatten_iteratorÚ _with_optionsÚprocess_query_conditionallyÚ process_query)r.Ú conditionalrVÚoptsÚopts r0r‘zQuery._optionsXsÍ€ð Ô+×0Ò0Ñ2Ô2ˆÔØ "¨$Ô*:Ð :Ð :Ý8;¹¼ˆDÔ Ð4Ñ 5Ý•TÔ*¨4Ñ0Ô0Ñ1Ô1ˆØ!Ô/°$Ñ6ˆÔØ ð (Øð 6ð 6�Ø×/Ò/°Ñ5Ô5Ð5Ð5ð 6ð 6ðð (ð (�Ø×!Ò! $Ñ'Ô'Ð'Ð'ð (ð (r2có—||¦«S)aÚReturn a new :class:`_query.Query` object transformed by the given function. E.g.:: def filter_something(criterion): def transform(q): return q.filter(criterion) return transform q = q.with_transformation(filter_something(x==5)) This allows ad-hoc recipes to be created for :class:`_query.Query` objects. See the example at :ref:`hybrid_transformers`. r))r.Úfns r0Úwith_transformationzQuery.with_transformationhs€ð"ˆr�$‰xŒxˆr2Ú*cóZ—|�t|¦«j}|xj|||ffz c_dS)a”Add an indexing or other executional context hint for the given entity or selectable to this :class:`_query.Query`. Functionality is passed straight through to :meth:`_expression.Select.with_hint`, with the addition that ``selectable`` can be a :class:`_schema.Table`, :class:`_expression.Alias`, or ORM entity / mapped class /etc. .. seealso:: :meth:`_query.Query.with_statement_hint` :meth:`.Query.prefix_with` - generic SELECT prefixing which also can suit some database-specific HINT syntaxes such as MySQL optimizer hints N)rrGÚ _with_hints)r.rGÚtextÚ dialect_names r0Ú with_hintzQuery.with_hint{s>€ð. Ð !Ý  Ñ,Ô,Ô7ˆJà ÐÔ˜j¨$° Ð=Ð?Ñ?ÐÔÐÐr2có0—| d||¦«S)aÊAdd a statement hint to this :class:`_expression.Select`. This method is similar to :meth:`_expression.Select.with_hint` except that it does not require an individual table, and instead applies to the statement as a whole. This feature calls down into :meth:`_expression.Select.with_statement_hint`. .. versionadded:: 1.0.0 .. seealso:: :meth:`_query.Query.with_hint` N)r©)r.r§r¨s r0Úwith_statement_hintzQuery.with_statement_hint—s€ð$�~Š~˜d D¨,Ñ7Ô7Ð7r2có—|jS)z²Get the non-SQL options which will take effect during execution. .. versionadded:: 1.3 .. seealso:: :meth:`_query.Query.execution_options` )r%r�s r0Úget_execution_optionszQuery.get_execution_options«s €ðÔ&Ð&r2c óD—|j |¦«|_dS)a§Set non-SQL options which take effect during execution. The options are the same as those accepted by :meth:`_engine.Connection.execution_options`. Note that the ``stream_results`` execution option is enabled automatically if the :meth:`~sqlalchemy.orm.query.Query.yield_per()` method is used. .. seealso:: :meth:`_query.Query.get_execution_options` N)r%r&©r.Úkwargss r0Úexecution_optionszQuery.execution_options¶s#€ð #'Ô"9×"?Ò"?ÀÑ"GÔ"GˆÔÐÐr2z0.9zœThe :meth:`_query.Query.with_lockmode` method is deprecated and will be removed in a future release. Please refer to :meth:`_query.Query.with_for_update`. cóD—t |¦«|_dS)a"Return a new :class:`_query.Query` object with the specified "locking mode", which essentially refers to the ``FOR UPDATE`` clause. :param mode: a string representing the desired locking mode. Valid values are: * ``None`` - translates to no lockmode * ``'update'`` - translates to ``FOR UPDATE`` (standard SQL, supported by most dialects) * ``'update_nowait'`` - translates to ``FOR UPDATE NOWAIT`` (supported by Oracle, PostgreSQL 8.1 upwards) * ``'read'`` - translates to ``LOCK IN SHARE MODE`` (for MySQL), and ``FOR SHARE`` (for PostgreSQL) .. seealso:: :meth:`_query.Query.with_for_update` - improved API for specifying the ``FOR UPDATE`` clause. N)Ú LockmodeArgÚparse_legacy_queryrK)r.Úmodes r0Ú with_lockmodezQuery.with_lockmodeÈs!€õB +×=Ò=¸dÑCÔCˆÔÐÐr2có8—t|||||¬¦«|_dS)a™return a new :class:`_query.Query` with the specified options for the ``FOR UPDATE`` clause. The behavior of this method is identical to that of :meth:`_expression.GenerativeSelect.with_for_update`. When called with no arguments, the resulting ``SELECT`` statement will have a ``FOR UPDATE`` clause appended. When additional arguments are specified, backend-specific options such as ``FOR UPDATE NOWAIT`` or ``LOCK IN SHARE MODE`` can take effect. E.g.:: q = sess.query(User).populate_existing().with_for_update(nowait=True, of=User) The above query on a PostgreSQL backend will render like:: SELECT users.id AS users_id FROM users FOR UPDATE OF users NOWAIT .. versionadded:: 0.9.0 :meth:`_query.Query.with_for_update` supersedes the :meth:`_query.Query.with_lockmode` method. .. note:: It is generally a good idea to combine the use of the :meth:`_orm.Query.populate_existing` method when using the :meth:`_orm.Query.with_for_update` method. The purpose of :meth:`_orm.Query.populate_existing` is to force all the data read from the SELECT to be populated into the ORM objects returned, even if these objects are already in the :term:`identity map`. .. seealso:: :meth:`_expression.GenerativeSelect.with_for_update` - Core level method with full argument and behavioral description. :meth:`_orm.Query.populate_existing` - overwrites attributes of objects already loaded in the identity map. )ÚreadÚnowaitÚofÚ skip_lockedÚ key_shareN)r³rK)r.r¸r¹rºr»r¼s r0Úwith_for_updatezQuery.with_for_updateës1€õf +ØØØØ#Øð  ñ ô ˆÔÐÐr2có"—t|¦«dkr| |d¦«n't|¦«dkrtjd¦«‚|j ¦«|_|j |¦«dS)aƒAdd values for bind parameters which may have been specified in filter(). Parameters may be specified using \**kwargs, or optionally a single dictionary as the first positional argument. The reason for both is that \**kwargs is convenient, however some parameter dictionaries contain unicode keys in which case \**kwargs cannot be used. rrzFparams() takes zero or one positional argument, which is a dictionary.N)rcr»rZr[rôr?)r.rVr°s r0rõz Query.params&sˆ€õ ˆt‰9Œ9˜Š>ˆ>Ø �MŠM˜$˜qœ'Ñ "Ô "Ð "Ð "Ý �‰YŒY˜Š]ˆ]ÝÔ&ð)ñôð ð”|×(Ò(Ñ*Ô*ˆŒ Ø Œ ×Ò˜FÑ#Ô#Ð#Ð#Ð#r2có¼—t|¦«D]K}tj|¦«}| |dd¦«}|j�|j|z|_ŒD||_ŒLdS)a!Apply the given filtering criterion to a copy of this :class:`_query.Query`, using SQL expressions. e.g.:: session.query(MyClass).filter(MyClass.name == 'some name') Multiple criteria may be specified as comma separated; the effect is that they will be joined together using the :func:`.and_` function:: session.query(MyClass).\ filter(MyClass.name == 'some name', MyClass.id > 5) The criterion is any SQL expression object applicable to the WHERE clause of a select. String expressions are coerced into SQL expression constructs via the :func:`_expression.text` construct. .. seealso:: :meth:`_query.Query.filter_by` - filter on keyword expressions. TN)rFr!Ú_expression_literal_as_textrrÉ©r.Ú criterions r0rfz Query.filter;sk€õ4˜i™œð ,ð ,ˆIÝ"Ô>¸yÑIÔIˆIà×*Ò*¨9°d¸DÑAÔAˆIàŒÐ*Ø"&¤/°IÑ"=�”�à"+�”�ð ,ð ,r2c óÖ‡—| ¦«Š‰€)tjd| ¦«z¦«‚ˆfd„| ¦«D¦«}|j|ŽS)aÚApply the given filtering criterion to a copy of this :class:`_query.Query`, using keyword expressions. e.g.:: session.query(MyClass).filter_by(name = 'some name') Multiple criteria may be specified as comma separated; the effect is that they will be joined together using the :func:`.and_` function:: session.query(MyClass).\ filter_by(name = 'some name', id = 5) The keyword expressions are extracted from the primary entity of the query, or the last entity that was the target of a call to :meth:`_query.Query.join`. .. seealso:: :meth:`_query.Query.filter` - filter on SQL expressions. Nz§Can't use filter_by when the first entity '%s' of a query is not a mapped class. Please use the filter method instead, or change the order of the entities in the querycó>•—g|]\}}t‰|¦«|k‘ŒSr)r )r�r3r Úzeros €r0rƒz#Query.filter_by..�s<ø€ð ð ð á��Uõ ˜t SÑ )Ô )¨UÒ 2ð ð ð r2)r­rZr´r¡Úitemsrf)r.r°ÚclausesrÅs @r0Ú filter_byzQuery.filter_by_s�ø€ð2×#Ò#Ñ%Ô%ˆØ ˆ<ÝÔ,ðCð×)Ò)Ñ+Ô+ñ,ñôð ð ð ð ð à$Ÿlšl™nœnð ñ ô ˆðˆtŒ{˜GÐ$Ð$r2có—t|¦«dkr-|ddurd|jvrd|_dS|d€ d|_dS| |¦«}|jdus|j€ ||_dS|j|z|_dS)agApply one or more ORDER BY criterion to the query and return the newly resulting :class:`_query.Query`. All existing ORDER BY settings can be suppressed by passing ``None`` - this will suppress any ordering configured on the :func:`.mapper` object using the deprecated :paramref:`.mapper.order_by` parameter. rrFrÎN)rcrërÎr…rÁs r0r¿zQuery.order_by‡s—€õ ˆy‰>Œ>˜QÒ Ð Ø˜Œ|˜uÐ$Ð$Ø $¤-Ð/Ð/Ø%*�D”NØ�ؘŒ|Ð#Ø!%�”Ø�à×(Ò(¨Ñ3Ô3ˆ à Œ>˜UÐ "Ð " d¤nÐ&<Ø&ˆDŒNˆNˆNà!œ^¨iÑ7ˆDŒNˆNˆNr2cóú—t|¦«dkr|d€ d|_dSttd„|D¦«Ž¦«}| |¦«}|jdur ||_dS|j|z|_dS)aŽApply one or more GROUP BY criterion to the query and return the newly resulting :class:`_query.Query`. All existing GROUP BY settings can be suppressed by passing ``None`` - this will suppress any GROUP BY configured on mappers as well. .. versionadded:: 1.1 GROUP BY can be cancelled by passing ``None``, in the same way as ORDER BY. rrNFcó,—g|]}t|¦«‘ŒSr)rr;s r0rƒz"Query.group_by..¶s€Ð DÐ DÐ D°Q¥¨a¡¤Ð DÐ DÐ Dr2)rcrÍrFrr…rÁs r0Úgroup_byzQuery.group_by£s‰€õ ˆy‰>Œ>˜QÒ Ð Ø˜Œ|Ð#Ø!&�”Ø�å�Ð DÐ D¸)Ð DÑ DÔ DÐEÑFÔFˆ Ø×(Ò(¨Ñ3Ô3ˆ à Œ>˜UÐ "Ð "Ø&ˆDŒNˆNˆNà!œ^¨iÑ7ˆDŒNˆNˆNr2cóú—tj|¦«}|�.t|tj¦«st jd¦«‚| |dd¦«}|j�|j|z|_dS||_dS)aApply a HAVING criterion to the query and return the newly resulting :class:`_query.Query`. :meth:`_query.Query.having` is used in conjunction with :meth:`_query.Query.group_by`. HAVING criterion makes it possible to use filters on aggregate functions like COUNT, SUM, AVG, MAX, and MIN, eg.:: q = session.query(User.id).\ join(User.addresses).\ group_by(User.id).\ having(func.count(Address.id) > 2) NzHhaving() argument must be of type sqlalchemy.sql.ClauseElement or stringT) r!rÀr^rÚ ClauseElementrZr[rrwrÁs r0Úhavingz Query.having¾s‹€õ$Ô:¸9ÑEÔEˆ à Ð ­Ø •sÔ(ñ* ô* Ð õÔ&ð9ñôð ð ×&Ò& y°$¸Ñ=Ô=ˆ à Œ<Ð #Øœ<¨)Ñ3ˆDŒLˆLˆLà$ˆDŒLˆLˆLr2cóz—| ||gt|¦«zަ« d¦«Sr‹)rnrFrt)r.Úexpr_fnrís r0Ú_set_opz Query._set_opás?€Ø×$Ò$Ø ˆG�t�f�t A™wœwÑ&Ð (ñ ô ç !Ò ! %Ñ (Ô (ð )r2có2—|jtjg|¢RŽS)a”Produce a UNION of this Query against one or more queries. e.g.:: q1 = sess.query(SomeClass).filter(SomeClass.foo=='bar') q2 = sess.query(SomeClass).filter(SomeClass.bar=='foo') q3 = q1.union(q2) The method accepts multiple Query objects so as to control the level of nesting. A series of ``union()`` calls such as:: x.union(y).union(z).all() will nest on each ``union()``, and produces:: SELECT * FROM (SELECT * FROM (SELECT * FROM X UNION SELECT * FROM y) UNION SELECT * FROM Z) Whereas:: x.union(y, z).all() produces:: SELECT * FROM (SELECT * FROM X UNION SELECT * FROM y UNION SELECT * FROM Z) Note that many database backends do not allow ORDER BY to be rendered on a query called within UNION, EXCEPT, etc. To disable all ORDER BY clauses including those configured on mappers, issue ``query.order_by(None)`` - the resulting :class:`_query.Query` object will not render ORDER BY within its SELECT statement. )rÒr!r&©r.rís r0r&z Query.unionæs"€ðJˆtŒ|�JÔ,Ð1¨qÐ1Ð1Ð1Ð1r2có2—|jtjg|¢RŽS)z¾Produce a UNION ALL of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. )rÒr!Ú union_allrÔs r0rÖzQuery.union_all ó!€ðˆtŒ|�JÔ0Ð5°1Ð5Ð5Ð5Ð5r2có2—|jtjg|¢RŽS)z¿Produce an INTERSECT of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. )rÒr!Ú intersectrÔs r0rÙzQuery.intersectr×r2có2—|jtjg|¢RŽS)zÃProduce an INTERSECT ALL of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. )rÒr!Ú intersect_allrÔs r0rÛzQuery.intersect_alls!€ðˆtŒ|�JÔ4Ð9°qÐ9Ð9Ð9Ð9r2có2—|jtjg|¢RŽS)z¼Produce an EXCEPT of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. )rÒr!Úexcept_rÔs r0rÝz Query.except_(s!€ðˆtŒ|�JÔ.Ð3°Ð3Ð3Ð3Ð3r2có2—|jtjg|¢RŽS)zÀProduce an EXCEPT ALL of this Query against one or more queries. Works the same way as :meth:`~sqlalchemy.orm.query.Query.union`. See that method for usage examples. )rÒr!Ú except_allrÔs r0rßzQuery.except_all1s!€ðˆtŒ|�JÔ1Ð6°AÐ6Ð6Ð6Ð6r2cóT—| dd¦«| dd¦«| dd¦«| dd¦«f\}}}}|r2tdd t|¦«¦«z¦«‚| |||||¬¦«S) aO-Create a SQL JOIN against this :class:`_query.Query` object's criterion and apply generatively, returning the newly resulting :class:`_query.Query`. **Simple Relationship Joins** Consider a mapping between two classes ``User`` and ``Address``, with a relationship ``User.addresses`` representing a collection of ``Address`` objects associated with each ``User``. The most common usage of :meth:`_query.Query.join` is to create a JOIN along this relationship, using the ``User.addresses`` attribute as an indicator for how this should occur:: q = session.query(User).join(User.addresses) Where above, the call to :meth:`_query.Query.join` along ``User.addresses`` will result in SQL approximately equivalent to:: SELECT user.id, user.name FROM user JOIN address ON user.id = address.user_id In the above example we refer to ``User.addresses`` as passed to :meth:`_query.Query.join` as the "on clause", that is, it indicates how the "ON" portion of the JOIN should be constructed. To construct a chain of joins, multiple :meth:`_query.Query.join` calls may be used. The relationship-bound attribute implies both the left and right side of the join at once:: q = session.query(User).\ join(User.orders).\ join(Order.items).\ join(Item.keywords) .. note:: as seen in the above example, **the order in which each call to the join() method occurs is important**. Query would not, for example, know how to join correctly if we were to specify ``User``, then ``Item``, then ``Order``, in our chain of joins; in such a case, depending on the arguments passed, it may raise an error that it doesn't know how to join, or it may produce invalid SQL in which case the database will raise an error. In correct practice, the :meth:`_query.Query.join` method is invoked in such a way that lines up with how we would want the JOIN clauses in SQL to be rendered, and each call should represent a clear link from what precedes it. **Joins to a Target Entity or Selectable** A second form of :meth:`_query.Query.join` allows any mapped entity or core selectable construct as a target. In this usage, :meth:`_query.Query.join` will attempt to create a JOIN along the natural foreign key relationship between two entities:: q = session.query(User).join(Address) In the above calling form, :meth:`_query.Query.join` is called upon to create the "on clause" automatically for us. This calling form will ultimately raise an error if either there are no foreign keys between the two entities, or if there are multiple foreign key linkages between the target entity and the entity or entities already present on the left side such that creating a join requires more information. Note that when indicating a join to a target without any ON clause, ORM configured relationships are not taken into account. **Joins to a Target with an ON Clause** The third calling form allows both the target entity as well as the ON clause to be passed explicitly. A example that includes a SQL expression as the ON clause is as follows:: q = session.query(User).join(Address, User.id==Address.user_id) The above form may also use a relationship-bound attribute as the ON clause as well:: q = session.query(User).join(Address, User.addresses) The above syntax can be useful for the case where we wish to join to an alias of a particular target entity. If we wanted to join to ``Address`` twice, it could be achieved using two aliases set up using the :func:`~sqlalchemy.orm.aliased` function:: a1 = aliased(Address) a2 = aliased(Address) q = session.query(User).\ join(a1, User.addresses).\ join(a2, User.addresses).\ filter(a1.email_address=='ed@foo.com').\ filter(a2.email_address=='ed@bar.com') The relationship-bound calling form can also specify a target entity using the :meth:`_orm.PropComparator.of_type` method; a query equivalent to the one above would be:: a1 = aliased(Address) a2 = aliased(Address) q = session.query(User).\ join(User.addresses.of_type(a1)).\ join(User.addresses.of_type(a2)).\ filter(a1.email_address == 'ed@foo.com').\ filter(a2.email_address == 'ed@bar.com') **Joining to Tables and Subqueries** The target of a join may also be any table or SELECT statement, which may be related to a target entity or not. Use the appropriate ``.subquery()`` method in order to make a subquery out of a query:: subq = session.query(Address).\ filter(Address.email_address == 'ed@foo.com').\ subquery() q = session.query(User).join( subq, User.id == subq.c.user_id ) Joining to a subquery in terms of a specific relationship and/or target entity may be achieved by linking the subquery to the entity using :func:`_orm.aliased`:: subq = session.query(Address).\ filter(Address.email_address == 'ed@foo.com').\ subquery() address_subq = aliased(Address, subq) q = session.query(User).join( User.addresses.of_type(address_subq) ) **Controlling what to Join From** In cases where the left side of the current state of :class:`_query.Query` is not in line with what we want to join from, the :meth:`_query.Query.select_from` method may be used:: q = session.query(Address).select_from(User).\ join(User.addresses).\ filter(User.name == 'ed') Which will produce SQL similar to:: SELECT address.* FROM user JOIN address ON user.id=address.user_id WHERE user.name = :name_1 **Legacy Features of Query.join()** The :meth:`_query.Query.join` method currently supports several usage patterns and arguments that are considered to be legacy as of SQLAlchemy 1.3. A deprecation path will follow in the 1.4 series for the following features: * Joining on relationship names rather than attributes:: session.query(User).join("addresses") **Why it's legacy**: the string name does not provide enough context for :meth:`_query.Query.join` to always know what is desired, notably in that there is no indication of what the left side of the join should be. This gives rise to flags like ``from_joinpoint`` as well as the ability to place several join clauses in a single :meth:`_query.Query.join` call which don't solve the problem fully while also adding new calling styles that are unnecessary and expensive to accommodate internally. **Modern calling pattern**: Use the actual relationship, e.g. ``User.addresses`` in the above case:: session.query(User).join(User.addresses) * Automatic aliasing with the ``aliased=True`` flag:: session.query(Node).join(Node.children, aliased=True).\ filter(Node.name == 'some name') **Why it's legacy**: the automatic aliasing feature of :class:`_query.Query` is intensely complicated, both in its internal implementation as well as in its observed behavior, and is almost never used. It is difficult to know upon inspection where and when its aliasing of a target entity, ``Node`` in the above case, will be applied and when it won't, and additionally the feature has to use very elaborate heuristics to achieve this implicit behavior. **Modern calling pattern**: Use the :func:`_orm.aliased` construct explicitly:: from sqlalchemy.orm import aliased n1 = aliased(Node) session.query(Node).join(Node.children.of_type(n1)).\ filter(n1.name == 'some name') * Multiple joins in one call:: session.query(User).join("orders", "items") session.query(User).join(User.orders, Order.items) session.query(User).join( (Order, User.orders), (Item, Item.order_id == Order.id) ) # ... and several more forms actually **Why it's legacy**: being able to chain multiple ON clauses in one call to :meth:`_query.Query.join` is yet another attempt to solve the problem of being able to specify what entity to join from, and is the source of a large variety of potential calling patterns that are internally expensive and complicated to parse and accommodate. **Modern calling pattern**: Use relationship-bound attributes or SQL-oriented ON clauses within separate calls, so that each call to :meth:`_query.Query.join` knows what the left side should be:: session.query(User).join(User.orders).join( Item, Item.order_id == Order.id) :param \*props: Incoming arguments for :meth:`_query.Query.join`, the props collection in modern use should be considered to be a one or two argument form, either as a single "target" entity or ORM attribute-bound relationship, or as a target entity plus an "on clause" which may be a SQL expression or ORM attribute-bound relationship. :param isouter=False: If True, the join used will be a left outer join, just as if the :meth:`_query.Query.outerjoin` method were called. :param full=False: render FULL OUTER JOIN; implies ``isouter``. .. versionadded:: 1.1 :param from_joinpoint=False: When using ``aliased=True``, a setting of True here will cause the join to be from the most recent joined target, rather than starting back from the original FROM clauses of the query. .. note:: This flag is considered legacy. :param aliased=False: If True, indicate that the JOIN target should be anonymously aliased. Subsequent calls to :meth:`_query.Query.filter` and similar will adapt the incoming criterion to the target alias, until :meth:`_query.Query.reset_joinpoint` is called. .. note:: This flag is considered legacy. .. seealso:: :ref:`ormtutorial_joins` in the ORM tutorial. :ref:`inheritance_toplevel` for details on how :meth:`_query.Query.join` is used for inheritance relationships. :func:`_orm.join` - a standalone ORM-level join function, used internally by :meth:`_query.Query.join`, which in previous SQLAlchemy versions was the primary ORM-level joining interface. rFÚfrom_joinpointÚisouterÚfullúunknown arguments: %sú, ©Ú outerjoinrãÚcreate_aliasesrá©rpÚ TypeErrorrÚsortedÚ_join)r.Úpropsr°rrárârãs r0rz Query.join:s¼€ðh �JŠJ�y %Ñ (Ô (Ø �JŠJÐ'¨Ñ /Ô /Ø �JŠJ�y %Ñ (Ô (Ø �JŠJ�v˜uÑ %Ô %ð 2 Ñ.ˆ� ¨$ð ð ÝØ'¨$¯)ª)µF¸6±N´NÑ*CÔ*CÑCñôð ð�zŠzØ ØØØ"Ø)ð ñ ô ð r2có"—| dd¦«| dd¦«| dd¦«}}}|r2tdd t|¦«¦«z¦«‚| |d|||¬¦«S) zùCreate a left outer join against this :class:`_query.Query` object's criterion and apply generatively, returning the newly resulting :class:`_query.Query`. Usage is the same as the :meth:`_query.Query.join` method. rFrárãräråTræré)r.rír°rrárãs r0rçzQuery.outerjoin_ s£€ð �JŠJ�y %Ñ (Ô (Ø �JŠJÐ'¨Ñ /Ô /Ø �JŠJ�v˜uÑ %Ô %ð"&�ˆð ð ÝØ'¨$¯)ª)µF¸6±N´NÑ*CÔ*CÑCñôð ð�zŠzØ ØØØ"Ø)ð ñ ô ð r2có°—||_d|vrC|d\}}| ¦«}| ¦«||<||f|d<|}d|v°C||_dS)NÚprev)r¬r?rv)r.ÚjpÚfrðs r0Ú_update_joinpointzQuery._update_joinpointx si€ØˆŒð˜ˆlˆlؘ”j‰GˆAˆtØ—9’9‘;”;ˆDØ—g’g‘i”iˆD�‰GؘT˜ˆBˆv‰J؈B𠘈lˆl𠈌ˆˆr2c ó€—|s| ¦«t|¦«dkrbt|dtjt t f¦«r5t|dttjtj f¦«r|f}tj |¦«}t|¦«D�] \}}t|t¦«r|\}} nd} t|tj tjf¦«r| |} } n|| } } | €:t!| ¦«} | js$t%| d¦«st'jd¦«‚t| tj ¦«rt+| dd¦«} nd} t| tj¦«r#t-| ¦«| ¦«} nl|rjt| tj ¦«rP| ¦«}t!|¦«}t+|dd¦«| jurt-|| j¦«} t| tj ¦«�rn| €W| r| } nR| j} | j} nB#t8$r5}tjt'jd| z¦«|¬ ¦«Yd}~nd}~wwxYw| j}|j |d¦«}t|t@¦«r6|j! "|¦«r|j#}t+|| j¦«} | j}t| tHj%¦«s|} |s‚|| |jf}||j&vro|j&| '¦«}||j&f|d <| (|¦«|t|¦«dz krtj)d |z¦«�Œíndx}}| *|| | ||||¦«�ŒdS) zÂConsumes arguments from :meth:`_query.Query.join` or :meth:`_query.Query.outerjoin`, places them into a consistent format with which to form the actual JOIN constructs. rrrNrAz9Expected mapped entity or selectable/table as join targetÚ_of_typez0Join target %s does not refer to a mapped entityrBrðz:Pathed join target %s has already been joined to; skipping)+Ú_reset_joinpointrcr^r!rxÚtyperÚstrrÎrÚPropComparatorr r8Ú enumerateraÚ string_typesrr]rWrZr[Úgetattrr r­Ú _parententityr3rgrLÚAttributeErrorrIr,rvrrAÚisaÚ aliased_classrÚQueryableAttributer¬r?róÚwarnÚ_join_left_to_right)r.ÚkeysrçrãrèráÚkeylistÚidxÚarg1Úarg2ÚrightÚonclauseÚr_infoÚof_typeÚjp0rlrQÚleftr`r@Úedgerñs r0rìz Query._join„ sS€ðð $Ø × !Ò !Ñ #Ô #Ð #õ �‰IŒI˜ŠNˆNÝØ�Q”�*Ô/µµ|ÐDñôð õØ�Q”Ý•jÔ.µ Ô0IÐJñôð ð�7ˆDõ”,˜tÑ$Ô$ˆÝ" 7Ñ+Ô+ðy ñy ‰IˆC�ݘ$¥Ñ&Ô&ð ð"‘ ��d�dà�õ Ø•zÔ0µ$Ô2CÐDñôð -ð#'¨�x��à"&¨�x�àÐÝ  ™œ�ØÔ+ðµG¸FÀHÑ4MÔ4MðÝ Ô.ð:ñôðõ ˜(¥JÔ$=Ñ>Ô>ð Ý! (¨J¸Ñ=Ô=��à�å˜(¥DÔ$5Ñ6Ô6ð Eõ.¨d×.BÒ.BÑ.DÔ.DÀhÑOÔO��ð ð E¥JØ�*Ô3ñ%ô%ð Eð×*Ò*Ñ,Ô,�ݘs‘|”|�å˜4 ¨4Ñ0Ô0°HÔ4JÐJÐJÝ1°#°x´|ÑDÔD�Hå˜(¥JÔ$=Ñ>Ô>ñ; #ð�=ØðØ '˜˜à (Ô 1˜ð Ø$)¤L˜E˜EøÝ-ðððÝ œKÝ &Ô 4ð%4Ø6;ñ%<ñ!"ô!"ð14ð ñôððððððøøøøðøøøð Ô-�àÔ2×6Ò6°t¸TÑBÔB�õ˜e¥ZÑ0Ô0ð;°U´\×5EÒ5EÀdÑ5KÔ5Kð;Ø Ô.�DÝ& t¨X¬\Ñ:Ô:�HàÔ(�Ý! (­JÔ,IÑJÔJð$Ø#�Hà%ð!ð! %¨¬Ð2�DؘtœÐ.Ð.ð"œ_¨TÔ2×7Ò7Ñ9Ô9˜Ø&*¨D¬OÐ%<˜˜6™ Ø×.Ò.¨rÑ2Ô2Ð2ð¥# g¡,¤,°Ñ"2Ò2Ð2Ý œIð!;Ø=Añ!Bñôðñ!øð#Ð"��tð × $Ò $Ø�e˜X t¨^¸YÈñ ô ð ñ ðoy ðy sÈ>IÉ JÉ+JÊJcóH—|j ¦«|_|€ |�J‚| |||¦«\}}} n|€J‚| |¦«\}} ||ur|st jd|›d|›d�¦«‚| |||||¦«\} }}|�L|j|} |jd|…t| ||||¬¦«fz|j|dzd…z|_dS| �|j | j } n|} |jt| ||||¬¦«fz|_dS)zÆGiven raw "left", "right", "onclause" parameters consumed from a particular key within _join(), add a real ORMJoin object to our _from_obj list (or augment an existing one) NzCan't construct a join from z to z, they are the same entity)rârãr) r,r?Ú"_join_determine_implicit_left_sideÚ_join_place_explicit_left_siderZr´Ú _join_check_and_adapt_right_siderbÚorm_joinr5rG) r.rr r r@rèrçrãÚreplace_from_obj_indexÚuse_entity_indexr Ú left_clauses r0rzQuery._join_left_to_right s±€ð&*Ô%?×%DÒ%DÑ%FÔ%FˆÔ"à ˆ<ð�<�<�<ð ×7Ò7¸¸eÀXÑNÔNñ  ØØ&Ø Ð ð Ð#Ð#Ð#ð×3Ò3°DÑ9Ô9ñ Ø&Ø ð �5ˆ=ˆ= ˆ=ÝÔ,Ð,à)-¨¨¨u¨u¨uð6ñôð ð#'×"GÒ"GØ �%˜ 4¨ñ# ô# ш��xð "Ð -ðœ.Ð)?Ô@ˆKð”Ð6Ð 6Ð6Ô7åØ#ØØ Ø )Ø!ð ñôðñ ð”.Ð!7¸!Ñ!;Ð!=Ð!=Ô>ñ ?ð ŒNˆNˆNð  Ð+à"œnÐ-=Ô>ÔI� � à"� à!œ^ÝØ ¨¸)È$ðñôð/ñˆDŒNˆNˆNr2có¦—t|¦«}dx}}|jr‰tj|j|j|¦«}t |¦«dkr|d}|j|}�nit |¦«dkrt jd¦«‚t jd|›d�¦«‚|j�ri}t|j¦«D]Q\} } | j } | €Œt| ¦«} | |urŒ#t| t¦«r | | f|| j<ŒEd| f|| j<ŒRt| ¦«¦«} tj| |j|¦«}t |¦«dkr|| |d\}}nSt |¦«dkrt jd¦«‚t jd|›d�¦«‚t jd¦«‚|||fS)z­When join conditions don't express the left side explicitly, determine if an existing FROM or entity in this query can serve as the left hand side. NrraCan't determine which FROM clause to join from, there are multiple FROMS which can join to this entity. Please use the .select_from() method to establish an explicit left side, as well as providing an explcit ON clause if not present already to help resolve the ambiguity.zDon't know how to join to zª. Please use the .select_from() method to establish an explicit left side, as well as providing an explcit ON clause if not present already to help resolve the ambiguity.zgNo entities to join from; please use select_from() to establish the left entity/selectable of this join)rrbrEÚfind_left_clause_to_join_fromrGrcrZr´r5rúÚentity_zero_or_selectabler^r¨rFr)r.rr r r rrÚindexesÚ potentialÚ entity_indexr;rLÚent_infoÚ all_clausess r0rz(Query._join_determine_implicit_left_sidel s?€õ"˜‘”ˆà48Ð8ÐÐ!1à Œ>ðO õÔ<Ø” Ô 1°8ñôˆGõ�7‰|Œ|˜qÒ Ð Ø)0°¬Ð&Ø”~Ð&<Ô=�‘Ý�W‘” Ò!Ð!ÝÔ0ð2ñôðõÔ0Ð0ð 6;°U°Uð =ñôððŒ^ñ2 ðˆIÝ%.¨t¬~Ñ%>Ô%>ð Dð DÑ!� ˜cØÔ6�Ø�>ØÝ" 6™?œ?�ؘvÐ%Ð%Øõ ˜c¥=Ñ1Ô1ðDØ1=¸vÐ0F�I˜cœnÑ-Ð-à6:¸F°^�I˜hÔ1Ñ2Ð2å˜yŸ~š~Ñ/Ô/Ñ0Ô0ˆKÝÔ<ؘVÔ.°ñôˆGõ�7‰|Œ|˜qÒ Ð Ø)2°;¸wÀq¼zÔ3JÔ)KÑ&Ð  $ $Ý�W‘” Ò!Ð!ÝÔ0ð2ñôðõÔ0Ð0ð 6;°U°Uð =ñôðõÔ,ð1ñôð ð Ð+Ð-=Ð=Ð=r2có —dx}}t|¦«}|jrPtj|j|j¦«}t |¦«dkrt jd¦«‚|r|d}|€_|jrXt|d¦«rHt|j¦«D]3\}}t|t¦«r|  |¦«r|}nŒ4||fS)zøWhen join conditions express a left side explicitly, determine where in our existing list of FROM clauses we should join towards, or if we need to make a new join, and if so is it from one of our existing entities. NrzrCan't identify which entity in which to assign the left side of this join. Please use a more specific ON clause.rrA)rrbrEÚ#find_left_clause_that_matches_givenrGrcrZr´r5rWrúr^r¨Úcorresponds_to)r.rrrÚl_inforrr;s r0rz$Query._join_place_explicit_left_sideÔ s€ð259Ð8ÐÐ!1嘑”ˆØ Œ>ð 4ÝÔBØ” Ô 1ñôˆGõ�7‰|Œ|˜aÒÐÝÔ0ð!ñôððð 4Ø)0°¬Ð&ð #Ð *Ø”ð +嘠Ñ)Ô)ð +õ& d¤nÑ5Ô5ð ð ‘��Sõ˜c¥=Ñ1Ô1ð°c×6HÒ6HÈÑ6NÔ6NðØ'*Ð$Ø�Eøà%Ð'7Ð7Ð7r2cóL—t|¦«}t|¦«}d}|sƒt|dd¦«} | rp| jst| jt j¦«rJ|jp|jgD]:} tj |j| ¦«rtj | |j¦«rd}nŒ;|s|s*|j|jurtj d|jz¦«‚t|dd¦«|jt|dd¦«} } } | r6|r4|   |j¦«stj d|›d|›�¦«‚t|d¦«r|xj|fz c_d} |jrÅ|r|j} | jr| |dd¦«}n�|r…|  | j¦«s*tj d | j›d | jj›d �¦«‚t| t j¦«r|  ¦«} d} t1| | ¦«}n|rtj d ¦«‚| o*| o'| jrt| jt j¦«p|}| s|s|rt1|d¬ ¦«}d} | rB| sJ‚t7|| j¬¦«}|f|jz|_|s| | |¦«t|t j¦«r| |dd¦«}|s*|r(|  ||||j!f|j"fdœ¦«n d|i|_"|t|¦«|fS)zúTransform the "right" side of the join as well as the onclause according to polymorphic mapping translations, aliasing on the query or on the join, special cases where the right and left side have overlapping tables. FrANTz*Can't join table/selectable '%s' to itselfr@z Join target z9 does not correspond to the right side of join condition z Selectable 'z' is not derived from 'rbzpThe aliased=True parameter on query.join() only works with an ORM entity, not a plain selectable, as the target.)Úflat)Ú equivalents)r«rðr«)#rrürBr^rCr!ÚJoinrbrGrEÚselectables_overlaprZr´Ú common_parentrArWÚ_join_entitiesr¯Ú _is_lateralrÚis_derived_fromÚ descriptionr_r`rÚ_with_polymorphic_selectablerdrrHr™rDrÎrór3r¬)r.rr r r@rèr#r ÚoverlapÚ right_mapperrkÚright_selectableÚright_is_aliasedÚ need_adapterÚaliased_entityrSs r0rz&Query._join_check_and_adapt_right_side sP€õ˜‘”ˆÝ˜‘”ˆàˆØð Ý" 6¨8°TÑ:Ô:ˆLðð ØÔ-ð å˜lÔ=½z¼ÑOÔOð ð!%¤Ð E°6Ô3DÐ2Eðð�HÝÔ3ØÔ)¨8ñôðå"Ô6Ø  &Ô"3ñôðð #'˜Ø˜øð ð Ø)ð àÔ 6Ô#4Ð4Ð4ÝÔ,Ø<ØÔ#ñ$ñôð õ �F˜H dÑ +Ô +Ø Ô Ý �FÐ.°Ñ 6Ô 6ð)9Ð&ˆ ð ð àð ð!×.Ò.¨t¬{Ñ;Ô;ð õ Ô,Ð,à9>¸¸ÀÀðJñôð õ �6˜8Ñ $Ô $ð -Ø Ð Ô  F 9Ñ ,Ð Ô àˆ ð Ô #ð( àð +Ø#œ{� àÔ+ð# ð×*Ò*¨5°$¸Ñ>Ô>��àð ð(×7Ò7Ø Ô3ñôð õ!Ô4Ð4ð-Ô8Ð8Ð8Ø(Ô;ÔGÐGÐGðñôðõÐ.µ Ô0EÑFÔFð(Ø'7×'=Ò'=Ñ'?Ô'?Ð$Ø#'�Lõ   Ð.>Ñ?Ô?��Øð õÔ0ðñôðð ð Ø$Ð$ð ðÔ-ðÝØ Ô=½zÔ?Oñôððð ðð  ð °>ð ݘE¨Ð-Ñ-Ô-ˆE؈Là ð OØÐ Ð �<õ !Ø <Ô#CðñôˆGð%, :°Ô0DÑ#DˆDÔ ð "ð OØ×7Ò7¸ ÀgÑNÔNÐNõ �h¥ Ô 8Ñ 9Ô 9ð @Ø×)Ò)¨(°D¸$Ñ?Ô?ˆHðð ; $ð ;Ø × "Ò "à).Ø" E¨4¬8Ð4°d´oÐFððñ ô ð ð ð 3°EÐ:ˆDŒOà•g˜e‘n”n hÐ.Ð.r2có,—|j|_d|_dS©Nr))rvr¬r™r�s r0rözQuery._reset_joinpoint¸ s€Øœ.ˆŒØ!ˆÔÐÐr2có.—| ¦«dS)acReturn a new :class:`_query.Query`, where the "join point" has been reset back to the base FROM entities of the query. This method is usually used in conjunction with the ``aliased=True`` feature of the :meth:`_query.Query.join` method. See the example in :meth:`_query.Query.join` for how this is used. N)rör�s r0Úreset_joinpointzQuery.reset_joinpoint¼ s€ð ×ÒÑÔÐÐÐr2có2—| |d¦«dS)a�Set the FROM clause of this :class:`_query.Query` explicitly. :meth:`_query.Query.select_from` is often used in conjunction with :meth:`_query.Query.join` in order to control which entity is selected from on the "left" side of the join. The entity or selectable object here effectively replaces the "left edge" of any calls to :meth:`_query.Query.join`, when no joinpoint is otherwise established - usually, the default "join point" is the leftmost entity in the :class:`_query.Query` object's list of entities to be selected. A typical example:: q = session.query(Address).select_from(User).\ join(User.addresses).\ filter(User.name == 'ed') Which produces SQL equivalent to:: SELECT address.* FROM user JOIN address ON user.id=address.user_id WHERE user.name = :name_1 :param \*from_obj: collection of one or more entities to apply to the FROM clause. Entities can be mapped classes, :class:`.AliasedClass` objects, :class:`_orm.Mapper` objects as well as core :class:`_expression.FromClause` elements like subqueries. .. versionchanged:: 0.9 This method no longer applies the given FROM object to be the selectable from which matching entities select from; the :meth:`.select_entity_from` method now accomplishes this. See that method for a description of this behavior. .. seealso:: :meth:`_query.Query.join` :meth:`_query.Query.select_entity_from` FN©rn©r.rks r0Ú select_fromzQuery.select_fromÉ s!€ð^ ×Ò˜h¨Ñ.Ô.Ð.Ð.Ð.r2có4—| |gd¦«dS)aàSet the FROM clause of this :class:`_query.Query` to a core selectable, applying it as a replacement FROM clause for corresponding mapped entities. The :meth:`_query.Query.select_entity_from` method supplies an alternative approach to the use case of applying an :func:`.aliased` construct explicitly throughout a query. Instead of referring to the :func:`.aliased` construct explicitly, :meth:`_query.Query.select_entity_from` automatically *adapts* all occurrences of the entity to the target selectable. Given a case for :func:`.aliased` such as selecting ``User`` objects from a SELECT statement:: select_stmt = select([User]).where(User.id == 7) user_alias = aliased(User, select_stmt) q = session.query(user_alias).\ filter(user_alias.name == 'ed') Above, we apply the ``user_alias`` object explicitly throughout the query. When it's not feasible for ``user_alias`` to be referenced explicitly in many places, :meth:`_query.Query.select_entity_from` may be used at the start of the query to adapt the existing ``User`` entity:: q = session.query(User).\ select_entity_from(select_stmt).\ filter(User.name == 'ed') Above, the generated SQL will show that the ``User`` entity is adapted to our statement, even in the case of the WHERE clause: .. sourcecode:: sql SELECT anon_1.id AS anon_1_id, anon_1.name AS anon_1_name FROM (SELECT "user".id AS id, "user".name AS name FROM "user" WHERE "user".id = :id_1) AS anon_1 WHERE anon_1.name = :name_1 The :meth:`_query.Query.select_entity_from` method is similar to the :meth:`_query.Query.select_from` method, in that it sets the FROM clause of the query. The difference is that it additionally applies adaptation to the other parts of the query that refer to the primary entity. If above we had used :meth:`_query.Query.select_from` instead, the SQL generated would have been: .. sourcecode:: sql -- uses plain select_from(), not select_entity_from() SELECT "user".id AS user_id, "user".name AS user_name FROM "user", (SELECT "user".id AS id, "user".name AS name FROM "user" WHERE "user".id = :id_1) AS anon_1 WHERE "user".name = :name_1 To supply textual SQL to the :meth:`_query.Query.select_entity_from` method, we can make use of the :func:`_expression.text` construct. However, the :func:`_expression.text` construct needs to be aligned with the columns of our entity, which is achieved by making use of the :meth:`_expression.TextClause.columns` method:: text_stmt = text("select id, name from user").columns( User.id, User.name) q = session.query(User).select_entity_from(text_stmt) :meth:`_query.Query.select_entity_from` itself accepts an :func:`.aliased` object, so that the special options of :func:`.aliased` such as :paramref:`.aliased.adapt_on_names` may be used within the scope of the :meth:`_query.Query.select_entity_from` method's adaptation services. Suppose a view ``user_view`` also returns rows from ``user``. If we reflect this view into a :class:`_schema.Table`, this view has no relationship to the :class:`_schema.Table` to which we are mapped, however we can use name matching to select from it:: user_view = Table('user_view', metadata, autoload_with=engine) user_view_alias = aliased( User, user_view, adapt_on_names=True) q = session.query(User).\ select_entity_from(user_view_alias).\ order_by(User.name) .. versionchanged:: 1.1.7 The :meth:`_query.Query.select_entity_from` method now accepts an :func:`.aliased` object as an alternative to a :class:`_expression.FromClause` object. :param from_obj: a :class:`_expression.FromClause` object that will replace the FROM clause of this :class:`_query.Query`. It also may be an instance of :func:`.aliased`. .. seealso:: :meth:`_query.Query.select_from` TNr:r;s r0Úselect_entity_fromzQuery.select_entity_fromú s#€ðb ×Ò˜x˜j¨$Ñ/Ô/Ð/Ð/Ð/r2cóZ—t|t¦«rÜtj|¦«\}}}t|t¦«r t|t¦«r ||z dkrgSt|t¦«r|dkst|t¦«r|dkrt |¦«|S| ||¦«}|�t |¦«dd|j…St |¦«S|dkrt |¦«dSt |||dz…¦«dS)Nréÿÿÿÿr)r^Úslicer Ú decode_sliceÚintrFÚstep)r.ÚitemÚstartÚstoprDÚress r0Ú __getitem__zQuery.__getitem__m s'€Ý �d�EÑ "Ô "ð 6Ý $Ô 1°$Ñ 7Ô 7Ñ ˆE�4˜õ˜4¥Ñ%Ô%ð (å˜u¥cÑ*Ô*ð (ð˜5‘L AÒ%Ð%à� õ˜U¥CÑ(Ô(ð (¨U°QªY¨Yݘ4¥Ñ%Ô%ð.7Ø*.°ª(¨(å˜D‘z”z $Ô'Ð'à—*’*˜U DÑ)Ô)ˆCØÐݘC‘y”y ¨¨t¬yÐ!8Ô9Ð9å˜C‘y”yÐ à�rŠzˆzݘD‘z”z "”~Ð%å˜D ¨¨q© Ô1Ñ2Ô2°1Ô5Ð5r2cóP—|�8|�6|j�|jnd|_|dkr|xj|z c_||z |_n;|€ |�||_n/|�-|€+|j�|jnd|_|dkr|xj|z c_t|jt¦«r|jdkr d|_dSdSdS)aComputes the "slice" of the :class:`_query.Query` represented by the given indices and returns the resulting :class:`_query.Query`. The start and stop indices behave like the argument to Python's built-in :func:`range` function. This method provides an alternative to using ``LIMIT``/``OFFSET`` to get a slice of the query. For example, :: session.query(User).order_by(User.id).slice(1, 3) renders as .. sourcecode:: sql SELECT users.id AS users_id, users.name AS users_name FROM users ORDER BY users.id LIMIT ? OFFSET ? (2, 1) .. seealso:: :meth:`_query.Query.limit` :meth:`_query.Query.offset` Nr)rÌrËr^rC)r.rFrGs r0rAz Query.sliceŠ s΀ð> Ð  Ð!1Ø+/¬<Ð+C˜4œ<˜<ȈDŒLؘŠzˆzØ� ”  Ñ%� ” Ø ™,ˆDŒKˆKØ ˆ]˜tÐ/؈DŒKˆKØ Ð  4 <Ø+/¬<Ð+C˜4œ<˜<ȈDŒLؘŠzˆzØ� ”  Ñ%� ” å �d”l¥CÑ (Ô (ð ¨T¬\¸QÒ->Ð->؈DŒLˆLˆLð ð Ð->Ð->r2có—||_dS)zfApply a ``LIMIT`` to the query and return the newly resulting :class:`_query.Query`. N)rË)r.Úlimits r0rLz Query.limit¸ s€ð ˆŒ ˆ ˆ r2có—||_dS)zhApply an ``OFFSET`` to the query and return the newly resulting :class:`_query.Query`. N)rÌ)r.Úoffsets r0rNz Query.offsetÀ s€ð ˆŒ ˆ ˆ r2có¬—|s d|_dS| |¦«}t|jt¦«r|xj|z c_dS||_dS)a“Apply a ``DISTINCT`` to the query and return the newly resulting :class:`_query.Query`. .. note:: The :meth:`.distinct` call includes logic that will automatically add columns from the ORDER BY of the query to the columns clause of the SELECT statement, to satisfy the common need of the database backend that ORDER BY columns be part of the SELECT list when DISTINCT is used. These columns *are not* added to the list of columns actually fetched by the :class:`_query.Query`, however, so would not affect results. The columns are passed through when using the :attr:`_query.Query.statement` accessor, however. :param \*expr: optional column expressions. When present, the PostgreSQL dialect will render a ``DISTINCT ON ()`` construct. TN)rÏr…r^rF)r.Úexprs r0rÀzQuery.distinctÈ s]€ð.ð &Ø!ˆDŒNˆNˆNà×'Ò'¨Ñ-Ô-ˆDݘ$œ.­$Ñ/Ô/ð &Ø�” $Ñ&�”��à!%�”��r2cóF—|jr|xj|z c_dS||_dS)aÇApply the prefixes to the query and return the newly resulting :class:`_query.Query`. :param \*prefixes: optional prefixes, typically strings, not using any commas. In particular is useful for MySQL keywords and optimizer hints: e.g.:: query = sess.query(User.name).\ prefix_with('HIGH_PRIORITY').\ prefix_with('SQL_SMALL_RESULT', 'ALL').\ prefix_with('/*+ BKA(user) */') Would render:: SELECT HIGH_PRIORITY SQL_SMALL_RESULT ALL /*+ BKA(user) */ users.name AS users_name FROM users .. seealso:: :meth:`_expression.HasPrefixes.prefix_with` N)rx)r.Úprefixess r0Ú prefix_withzQuery.prefix_withè s-€ð4 Œ>ð &Ø ˆNŒN˜hÑ &ˆNŒNˆNˆNà%ˆDŒNˆNˆNr2cóF—|jr|xj|z c_dS||_dS)adApply the suffix to the query and return the newly resulting :class:`_query.Query`. :param \*suffixes: optional suffixes, typically strings, not using any commas. .. versionadded:: 1.0.0 .. seealso:: :meth:`_query.Query.prefix_with` :meth:`_expression.HasSuffixes.suffix_with` N)ry)r.Úsuffixess r0Ú suffix_withzQuery.suffix_with s-€ð" Œ>ð &Ø ˆNŒN˜hÑ &ˆNŒNˆNˆNà%ˆDŒNˆNˆNr2có —t|¦«S)aþReturn the results represented by this :class:`_query.Query` as a list. This results in an execution of the underlying SQL statement. .. warning:: The :class:`_query.Query` object, when asked to return either a sequence or iterator that consists of full ORM-mapped entities, will **deduplicate entries based on primary key**. See the FAQ for more details. .. seealso:: :ref:`faq_query_deduplicating` )rFr�s r0Úallz Query.all s€õ �D‰zŒzÐr2có°—tj|¦«}t|tjtjf¦«st jd¦«‚||_dS)a1Execute the given SELECT statement and return results. This method bypasses all internal statement compilation, and the statement is executed without modification. The statement is typically either a :func:`_expression.text` or :func:`_expression.select` construct, and should return the set of columns appropriate to the entity class represented by this :class:`_query.Query`. .. seealso:: :ref:`orm_tutorial_literal_sql` - usage examples in the ORM tutorial zBfrom_statement accepts text(), select(), and union() objects only.N)r!rÀr^Ú TextClauser_rZr[rÊ)r.rós r0Úfrom_statementzQuery.from_statement/ s_€õ&Ô:¸9ÑEÔEˆ åØ � Ô-­zÔ/DÐEñ ô ð õÔ&ð,ñôð ð $ˆŒˆˆr2có¨—|j�t|¦«dd…}nt|dd…¦«}t|¦«dkr|dSdS)a7Return the first result of this ``Query`` or None if the result doesn't contain any row. first() applies a limit of one within the generated SQL, so that only one primary entity row is generated on the server side (note this may consist of multiple result rows if join-loaded collections are present). Calling :meth:`_query.Query.first` results in an execution of the underlying query. .. seealso:: :meth:`_query.Query.one` :meth:`_query.Query.one_or_none` Nrr)rÊrFrc©r.Úrets r0Úfirstz Query.firstN sQ€ð( Œ?Ð &Ý�t‘*”*˜Q˜q˜S”/ˆCˆCå�t˜A˜a˜C”y‘/”/ˆCÝ ˆs‰8Œ8�aŠ<ˆ<Ø�q”6ˆMà�4r2có’—t|¦«}t|¦«}|dkr|dS|dkrdStjd¦«‚)a˜Return at most one result or raise an exception. Returns ``None`` if the query selects no rows. Raises ``sqlalchemy.orm.exc.MultipleResultsFound`` if multiple object identities are returned, or if multiple rows are returned for a query that returns only scalar values as opposed to full identity-mapped entities. Calling :meth:`_query.Query.one_or_none` results in an execution of the underlying query. .. versionadded:: 1.0.9 Added :meth:`_query.Query.one_or_none` .. seealso:: :meth:`_query.Query.first` :meth:`_query.Query.one` rrNz*Multiple rows were found for one_or_none())rFrcÚorm_excÚMultipleResultsFound)r.r^r‹s r0Ú one_or_nonezQuery.one_or_nonek sR€õ0�4‰jŒjˆå �‰HŒHˆØ �Š6ˆ6Ø�q”6ˆMØ �!ŠVˆVØ�4åÔ.Ø<ñôð r2cóæ— | ¦«}|€tjd¦«‚|S#tj$r3}t jtjd¦«|¬¦«Yd}~dSd}~wwxYw)aBReturn exactly one result or raise an exception. Raises ``sqlalchemy.orm.exc.NoResultFound`` if the query selects no rows. Raises ``sqlalchemy.orm.exc.MultipleResultsFound`` if multiple object identities are returned, or if multiple rows are returned for a query that returns only scalar values as opposed to full identity-mapped entities. Calling :meth:`.one` results in an execution of the underlying query. .. seealso:: :meth:`_query.Query.first` :meth:`_query.Query.one_or_none` NzNo row was found for one()z"Multiple rows were found for one()rB)rcraÚ NoResultFoundrbr rI)r.r^rQs r0Úonez Query.one� s©€ð$ Ø×"Ò"Ñ$Ô$ˆCðˆ{ÝÔ+Ð,HÑIÔIÐI؈JøõÔ+ð ð ð Ý ŒKÝÔ,Ø8ñôð!$ð  ñ ô ð ð ð ð ð ð ð øøøøð øøøs‚.®A0½(A+Á+A0có–— | ¦«}t|t¦«s|S|dS#tj$rYdSwxYw)a4Return the first element of the first result or None if no rows present. If multiple rows are returned, raises MultipleResultsFound. >>> session.query(Item).scalar() >>> session.query(Item.id).scalar() 1 >>> session.query(Item.id).filter(Item.id < 0).scalar() None >>> session.query(Item.id, Item.name).scalar() 1 >>> session.query(func.count(Parent.id)).scalar() 20 This results in an execution of the underlying query. rN)rfr^rararer]s r0Úscalarz Query.scalar¯ sY€ð& Ø—(’(‘*”*ˆCݘc¥5Ñ)Ô)ð Ø� Ø�q”6ˆMøÝÔ$ð ð ð Ø�4�4ð øøøs‚*5­5µAÁAcóº—| ¦«}d|j_|jr |js|j ¦«| |¦«Sr•)rñróÚ use_labelsrZrÛr+Ú_execute_and_instances)r.Úcontexts r0Ú__iter__zQuery.__iter__Ê sZ€Ø×'Ò'Ñ)Ô)ˆØ'+ˆÔÔ$Ø Œ?ð & 4Ô#:ð &Ø ŒL× #Ò #Ñ %Ô %Ð %Ø×*Ò*¨7Ñ3Ô3Ð3r2cóü—| ¦«} |jr | ||jj¦«nd}n#tj$rd}YnwxYwt |j |¦«¦«Sr=) rñr+Ú_get_bind_argsÚget_bindrZÚUnboundExecutionErrorrøróÚcompile)r.rlÚbinds r0Ú__str__z Query.__str__Ñ s�€Ø×'Ò'Ñ)Ô)ˆð ð”<ð�×#Ò# G¨T¬\Ô-BÑCÔCÐCàð ˆDøõ Ô+ð ð ð ØˆDˆDˆDð øøøå�7Ô$×,Ò,¨TÑ2Ô2Ñ3Ô3Ð3s–)AÁAÁAc ó\—|jjdi|¤Ž}|jr|jdi|j¤Ž}|Sr6)r+Ú connectionr%r±)r.ÚkwÚconns r0Ú_connection_from_sessionzQuery._connection_from_sessionÝ sH€Ø&ˆtŒ|Ô&Ð,Ð,¨Ð,Ð,ˆØ Ô "ð EØ)�4Ô)ÐDÐD¨DÔ,CÐDÐDˆD؈ r2có²—| ||jd¬¦«}| |j|j¦«}t j|j||¦«S)NT)Úclose_with_result)roryÚexecuterórôrÚ instancesÚquery)r.Ú querycontextrxÚresults r0rkzQuery._execute_and_instancesã sX€Ø×"Ò"Ø ˜$Ô7È4ð#ñ ô ˆð—’˜lÔ4°d´lÑCÔCˆÝÔ  Ô!3°V¸\ÑJÔJÐJr2cóh—| ||d¬¦«}| ||j¦«S)NT)rArœr{)ryr|rô)r.rörArxs r0Ú _execute_crudzQuery._execute_crudë s;€Ø×,Ò,Ø $¸$ð-ñ ô ˆð�|Š|˜D $¤,Ñ/Ô/Ð/r2c óF—|d| ¦«|jdœ|¤ŽS)N)rArœr))r²ró)r.rr¢rws r0rozQuery._get_bind_argsò s<€Øˆrð Ø×$Ò$Ñ&Ô&¨|Ô/Eð ð ØIKð ð ð r2có8—d„d„|jD¦«D¦«S)aReturn metadata about the columns which would be returned by this :class:`_query.Query`. Format is a list of dictionaries:: user_alias = aliased(User, name='user2') q = sess.query(User, User.id, user_alias) # this expression: q.column_descriptions # would return: [ { 'name':'User', 'type':User, 'aliased':False, 'expr':User, 'entity': User }, { 'name':'id', 'type':Integer(), 'aliased':False, 'expr':User.id, 'entity': User }, { 'name':'user2', 'type':User, 'aliased':True, 'expr':user_alias, 'entity': user_alias } ] c óž—g|]J\}}|j|jt|dd¦«|j|j�|jst|dd¦«nddœ‘ŒKS)r@FNrL)rør÷rrPrL)Ú _label_namer÷rürPr¥r¯)r�r;Úinsp_ents r0rƒz-Query.column_descriptions..s€€ð ð ð ñ��XðœØœÝ" 8Ð-?ÀÑGÔGØœà”?Ð.Ø Ô2ð/õ" (¨H°dÑ;Ô;Ð;ðð ð ð ð ð r2cóL—g|]!}||j�t|j¦«ndf‘Œ"Sr=)r¥r)r�Ú_ents r0rƒz-Query.column_descriptions..*sP€ð "ð "ð "ððð Ô+Ð7õ  Ô 0Ñ1Ô1Ð1à!ð ð "ð "ð "r2r r�s r0Úcolumn_descriptionszQuery.column_descriptions÷ sA€ðP ð ð "ð "ð!œNð "ñ "ô "ð ñ ô ð r2cóT—|}|€t|¦«}tj|||¦«S)aGiven a ResultProxy cursor as returned by connection.execute(), return an ORM result as an iterator. e.g.:: result = engine.execute("select * from users") for u in session.query(User).instances(result): print u )r'rr})r.ÚcursorÚ_Query__contextrls r0r}zQuery.instances7s0€ðˆØ ˆ?Ý" 4Ñ(Ô(ˆGåÔ   v¨wÑ7Ô7Ð7r2có.—tj|||¦«S)akMerge a result into this :class:`_query.Query` object's Session. Given an iterator returned by a :class:`_query.Query` of the same structure as this one, return an identical iterator of results, with all mapped instances merged into the session using :meth:`.Session.merge`. This is an optimized method which will merge all mapped instances, preserving the structure of the result rows and unmapped columns with less method overhead than that of calling :meth:`.Session.merge` explicitly for each value. The structure of the results is determined based on the column list of this :class:`_query.Query` - if these do not correspond, unchecked errors will occur. The 'load' argument is the same as that of :meth:`.Session.merge`. For an example of how :meth:`_query.Query.merge_result` is used, see the source code for the example :ref:`examples_caching`, where :meth:`_query.Query.merge_result` is used to efficiently restore state from a cache back into a target :class:`.Session`. )rÚ merge_result)r.ÚiteratorÚloads r0r�zQuery.merge_resultGs€õ4Ô# D¨(°DÑ9Ô9Ð9r2có`—|j|j|j|j|j|jpd|jdœS)N)rLrNrÀrRrUrÌrÏ)rËrÌrÏrxryrÍrwr�s r0Ú _select_argszQuery._select_argscs;€ð”[Ø”l؜؜؜؜Ð.¨$Ø”lð ð ð r2cóÄ—|j}| d¦«dupB| d¦«dup+| dd¦«p| dd¦«S)NrLrNrÀFrÌ)r“rvr¯s r0Ú_should_nest_selectablezQuery._should_nest_selectableosj€àÔ"ˆà �JŠJ�wÑ Ô  tÐ +ð -Ø�zŠz˜(Ñ#Ô#¨4Ð/ð -à�zŠz˜* eÑ,Ô,ð -ð�zŠz˜* eÑ,Ô,ð  r2cóð—tj| d¦« tjd¦«¦« ¦«j dg¦«¦«S)a‚A convenience method that turns a query into an EXISTS subquery of the form EXISTS (SELECT 1 FROM ... WHERE ...). e.g.:: q = session.query(User).filter(User.name == 'fred') session.query(q.exists()) Producing SQL similar to:: SELECT EXISTS ( SELECT 1 FROM users WHERE users.name = :name_1 ) AS anon_1 The EXISTS construct is usually used in the WHERE clause:: session.query(User.id).filter(q.exists()).scalar() Note that some databases such as SQL Server don't allow an EXISTS expression to be present in the columns clause of a SELECT. To select a simple boolean value based on the exists as a WHERE, use :func:`.literal`:: from sqlalchemy import literal session.query(literal(True)).filter(q.exists()).scalar() FÚ1r)rÚexistsrùrŒÚliteral_columnrúróÚwith_only_columnsr�s r0r˜z Query.existsys^€õFŒzØ × "Ò " 5Ñ )Ô )ß Š[�Ô+¨CÑ0Ô0Ñ 1Ô 1ß Š[‰]Œ]Ü ×(Ò(¨!¨Ñ-Ô-ñ  ô ð r2có²—tj tjd¦«¦«}| |¦« ¦«S)aãReturn a count of rows this the SQL formed by this :class:`Query` would return. This generates the SQL for this Query as follows:: SELECT count(1) AS count_1 FROM ( SELECT ) AS anon_1 The above SQL returns a single row, which is the aggregate value of the count function; the :meth:`_query.Query.count` method then returns that single integer value. .. warning:: It is important to note that the value returned by count() is **not the same as the number of ORM objects that this Query would return from a method such as the .all() method**. The :class:`_query.Query` object, when asked to return full entities, will **deduplicate entries based on primary key**, meaning if the same primary key value would appear in the results more than once, only one object of that primary key would be present. This does not apply to a query that is against individual columns. .. seealso:: :ref:`faq_query_deduplicating` :ref:`orm_tutorial_query_returning` For fine grained control over specific columns to count, to skip the usage of a subquery or otherwise control of the FROM clause, or to use other aggregate functions, use :attr:`~sqlalchemy.sql.expression.func` expressions in conjunction with :meth:`~.Session.query`, i.e.:: from sqlalchemy import func # count User records, without # using a subquery. session.query(func.count(User.id)) # return count of user "id" grouped # by "name" session.query(func.count(User.id)).\ group_by(User.name) from sqlalchemy import distinct # count distinct "name" values session.query(func.count(distinct(User.name))) r¤)rÚfuncr'r™rqrh)r.Úcols r0r'z Query.count£sA€õnŒh�nŠn�SÔ/°Ñ4Ô4Ñ5Ô5ˆØ�~Š~˜cÑ"Ô"×)Ò)Ñ+Ô+Ð+r2Úevaluatecóx—tj ||¦«}| ¦«|jS)afPerform a bulk delete query. Deletes rows matched by this query from the database. E.g.:: sess.query(User).filter(User.age == 25).\ delete(synchronize_session=False) sess.query(User).filter(User.age == 25).\ delete(synchronize_session='evaluate') .. warning:: The :meth:`_query.Query.delete` method is a "bulk" operation, which bypasses ORM unit-of-work automation in favor of greater performance. **Please read all caveats and warnings below.** :param synchronize_session: chooses the strategy for the removal of matched objects from the session. Valid values are: ``False`` - don't synchronize the session. This option is the most efficient and is reliable once the session is expired, which typically occurs after a commit(), or explicitly using expire_all(). Before the expiration, objects may still remain in the session which were in fact deleted which can lead to confusing results if they are accessed via get() or already loaded collections. ``'fetch'`` - performs a select query before the delete to find objects that are matched by the delete query and need to be removed from the session. Matched objects are removed from the session. ``'evaluate'`` - Evaluate the query's criteria in Python straight on the objects in the session. If evaluation of the criteria isn't implemented, an error is raised. The expression evaluator currently doesn't account for differing string collations between the database and Python. :return: the count of rows matched as returned by the database's "row count" feature. .. warning:: **Additional Caveats for bulk query deletes** * This method does **not work for joined inheritance mappings**, since the **multiple table deletes are not supported by SQL** as well as that the **join condition of an inheritance mapper is not automatically rendered**. Care must be taken in any multiple-table delete to first accommodate via some other means how the related table will be deleted, as well as to explicitly include the joining condition between those tables, even in mappings where this is normally automatic. E.g. if a class ``Engineer`` subclasses ``Employee``, a DELETE against the ``Employee`` table would look like:: session.query(Engineer).\ filter(Engineer.id == Employee.id).\ filter(Employee.name == 'dilbert').\ delete() However the above SQL will not delete from the Engineer table, unless an ON DELETE CASCADE rule is established in the database to handle it. Short story, **do not use this method for joined inheritance mappings unless you have taken the additional steps to make this feasible**. * The polymorphic identity WHERE criteria is **not** included for single- or joined- table updates - this must be added **manually** even for single table inheritance. * The method does **not** offer in-Python cascading of relationships - it is assumed that ON DELETE CASCADE/SET NULL/etc. is configured for any foreign key references which require it, otherwise the database may emit an integrity violation if foreign key references are being enforced. After the DELETE, dependent objects in the :class:`.Session` which were impacted by an ON DELETE may not contain the current state, or may have been deleted. This issue is resolved once the :class:`.Session` is expired, which normally occurs upon :meth:`.Session.commit` or can be forced by using :meth:`.Session.expire_all`. Accessing an expired object whose row has been deleted will invoke a SELECT to locate the row; when the row is not found, an :class:`~sqlalchemy.orm.exc.ObjectDeletedError` is raised. * The ``'fetch'`` strategy results in an additional SELECT statement emitted and will significantly reduce performance. * The ``'evaluate'`` strategy performs a scan of all matching objects within the :class:`.Session`; if the contents of the :class:`.Session` are expired, such as via a proceeding :meth:`.Session.commit` call, **this will result in SELECT queries emitted for every matching object**. * The :meth:`.MapperEvents.before_delete` and :meth:`.MapperEvents.after_delete` events **are not invoked** from this method. Instead, the :meth:`.SessionEvents.after_bulk_delete` method is provided to act upon a mass DELETE of entity rows. .. seealso:: :meth:`_query.Query.update` :ref:`inserts_and_updates` - Core SQL tutorial )r Ú BulkDeleteÚfactoryÚexec_Úrowcount)r.Úsynchronize_sessionÚ delete_ops r0Údeletez Query.deleteÝs7€õp Ô*×2Ò2°4Ð9LÑMÔMˆ Ø�ŠÑÔÐØÔ!Ð!r2có„—|pi}tj ||||¦«}| ¦«|jS)a Perform a bulk update query. Updates rows matched by this query in the database. E.g.:: sess.query(User).filter(User.age == 25).\ update({User.age: User.age - 10}, synchronize_session=False) sess.query(User).filter(User.age == 25).\ update({"age": User.age - 10}, synchronize_session='evaluate') .. warning:: The :meth:`_query.Query.update` method is a "bulk" operation, which bypasses ORM unit-of-work automation in favor of greater performance. **Please read all caveats and warnings below.** :param values: a dictionary with attributes names, or alternatively mapped attributes or SQL expressions, as keys, and literal values or sql expressions as values. If :ref:`parameter-ordered mode ` is desired, the values can be passed as a list of 2-tuples; this requires that the :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order` flag is passed to the :paramref:`.Query.update.update_args` dictionary as well. .. versionchanged:: 1.0.0 - string names in the values dictionary are now resolved against the mapped entity; previously, these strings were passed as literal column names with no mapper-level translation. :param synchronize_session: chooses the strategy to update the attributes on objects in the session. Valid values are: ``False`` - don't synchronize the session. This option is the most efficient and is reliable once the session is expired, which typically occurs after a commit(), or explicitly using expire_all(). Before the expiration, updated objects may still remain in the session with stale values on their attributes, which can lead to confusing results. ``'fetch'`` - performs a select query before the update to find objects that are matched by the update query. The updated attributes are expired on matched objects. ``'evaluate'`` - Evaluate the Query's criteria in Python straight on the objects in the session. If evaluation of the criteria isn't implemented, an exception is raised. The expression evaluator currently doesn't account for differing string collations between the database and Python. :param update_args: Optional dictionary, if present will be passed to the underlying :func:`_expression.update` construct as the ``**kw`` for the object. May be used to pass dialect-specific arguments such as ``mysql_limit``, as well as other special arguments such as :paramref:`~sqlalchemy.sql.expression.update.preserve_parameter_order`. .. versionadded:: 1.0.0 :return: the count of rows matched as returned by the database's "row count" feature. .. warning:: **Additional Caveats for bulk query updates** * The method does **not** offer in-Python cascading of relationships - it is assumed that ON UPDATE CASCADE is configured for any foreign key references which require it, otherwise the database may emit an integrity violation if foreign key references are being enforced. After the UPDATE, dependent objects in the :class:`.Session` which were impacted by an ON UPDATE CASCADE may not contain the current state; this issue is resolved once the :class:`.Session` is expired, which normally occurs upon :meth:`.Session.commit` or can be forced by using :meth:`.Session.expire_all`. * The ``'fetch'`` strategy results in an additional SELECT statement emitted and will significantly reduce performance. * The ``'evaluate'`` strategy performs a scan of all matching objects within the :class:`.Session`; if the contents of the :class:`.Session` are expired, such as via a proceeding :meth:`.Session.commit` call, **this will result in SELECT queries emitted for every matching object**. * The method supports multiple table updates, as detailed in :ref:`multi_table_updates`, and this behavior does extend to support updates of joined-inheritance and other multiple table mappings. However, the **join condition of an inheritance mapper is not automatically rendered**. Care must be taken in any multiple-table update to explicitly include the joining condition between those tables, even in mappings where this is normally automatic. E.g. if a class ``Engineer`` subclasses ``Employee``, an UPDATE of the ``Engineer`` local table using criteria against the ``Employee`` local table might look like:: session.query(Engineer).\ filter(Engineer.id == Employee.id).\ filter(Employee.name == 'dilbert').\ update({"engineer_type": "programmer"}) * The polymorphic identity WHERE criteria is **not** included for single- or joined- table updates - this must be added **manually**, even for single table inheritance. * The :meth:`.MapperEvents.before_update` and :meth:`.MapperEvents.after_update` events **are not invoked from this method**. Instead, the :meth:`.SessionEvents.after_bulk_update` method is provided to act upon a mass UPDATE of entity rows. .. seealso:: :meth:`_query.Query.delete` :ref:`inserts_and_updates` - Core SQL tutorial )r Ú BulkUpdater¡r¢r£)r.r‚r¤Ú update_argsÚ update_ops r0r»z Query.updateYsL€ðD"Ð' Rˆ ÝÔ*×2Ò2Ø Ð% v¨{ñ ô ˆ ð �ŠÑÔÐØÔ!Ð!r2cóÄ—|jjr0|jjD]#}||¦«}|�||ur|}|jsd|_Œ$t|¦«}|j�|S||_|j|_|jD]}| ||¦«Œ|j D]}|d}||g|dd…¢RŽŒ|j rt|j ¦«|_ |j r| |¦«|js/|jrt#jd¦«‚t#jd¦«‚|jr"|jr| |¦«|_n| |¦«|_|S)NFrrzyNo column-based properties specified for refresh operation. Use session.expire() to reload collections and related items.z4Query contains no columns with which to SELECT from.)ÚdispatchÚbefore_compileÚ_bake_okr'rórðrKr5Ú setup_contextÚcreate_eager_joinsÚ from_clauserFÚfromsroÚ_adjust_for_single_inheritanceÚprimary_columnsrßrZr´Úmulti_row_eager_loadersr•Ú_compound_eager_statementÚ_simple_statement)r.rðr¢Ú new_queryrlrLÚrecÚstrategys r0rñzQuery._compile_contextâsÃ€Ø Œ=Ô 'ð .Ø”mÔ2ð .ð .�ؘB˜t™HœH� ØÐ(¨Y¸dÐ-BÐ-BØ$�DØœ;ð.Ø(-˜œ øå˜tÑ$Ô$ˆà Ô Ð (؈NàˆŒà"&Ô"6ˆÔà”nð 0ð 0ˆFØ × Ò   wÑ /Ô /Ð /Ð /àÔ-ð (ð (ˆCؘ1”vˆHØ ˆH�WÐ '˜s 1 2 2œwÐ 'Ð 'Ð 'Ð 'Ð 'à Ô ð 6õ! Ô!4Ñ5Ô5ˆGŒMð Ô #ð 9Ø × /Ò /°Ñ 8Ô 8Ð 8àÔ&ð ØÔ$ð ÝÔ0ð?ñôðõ Ô0ØMñôðð Ô *ð @¨tÔ/Kð @Ø $× >Ò >¸wÑ GÔ GˆGÔ Ð à $× 6Ò 6°wÑ ?Ô ?ˆGÔ àˆr2cób—|jr tj|j|j¦«}n d|_g}t j|j|z|jf|j|j|jdœ|j ¤Ž}|j |_ |j D] }|j |Ž}Œ |j r|j|j Ž}| ¦«}| ¦«}tj||¦«|_t j|g|jz|j¬¦«}|j �|j j€ |j |_ |}|j ¦«D]}tj|||j¦«}Œ| |¦«|jr'|j|j |j¦«Ž|j|jŽ|S)N©rkrjr¿)rj)r¿rEÚ expand_column_list_from_order_byr´rÚselectrr²rðr“rKr¦r©rTrXr`rerFrSÚsecondary_columnsrºÚ eager_joinsr‚Ú splice_joinsÚstop_onÚ append_fromÚappend_order_byÚcopy_and_processÚeager_order_by) r.rlÚorder_by_col_exprÚinnerÚhintrmrór±Ú eager_joins r0r¶zQuery._compound_eager_statementsù€ð Ô ð #Ý (Ô IØÔ'¨Ô)9ñ!ô!Ð Ð ð $ˆGÔ Ø "Ð å” Ø Ô #Ð&7Ñ 7Ø Ô ð  ð”]Ø”~ðÔ%ð  ð  ðÔð  ð  ˆð!(Ô 7ˆÔàÔ$ð +ð +ˆDØ#�E”O TÐ*ˆEˆEà Œ?ð 6Ø#�E”O T¤_Ð5ˆEà— ’ ‘ ” ˆà×"Ò"Ñ$Ô$ˆå"Ô0°¸Ñ?Ô?ˆŒå”JØ ˆG�gÔ/Ñ /¸G¼Nð ñ ô ˆ ð Ô #Ð /ØÔ'Ô*Ð2à(/Ô(?ˆIÔ %àˆ Ø!Ô-×4Ò4Ñ6Ô6ð ð ˆJõ#Ô/ؘZ¨Ô);ñôˆKˆKð ×Ò˜kÑ*Ô*Ð*à Ô ð Ø %ˆIÔ %Ø”×1Ò1°'Ô2BÑCÔCð ð ð "ˆ Ô! 7Ô#9Ð:Ð:ØÐr2có—|jsd|_|jdur4|jr-|xjtj|j|j¦«z c_|xjt |j ¦«¦«z c_tj |j|j z|j f|j|j |jdœ|j¤Ž}|j|_|jD] }|j|Ž}Œ |jr|j|jŽ}|jr|j|jŽ|S)NTr¼)r¿rÏr´rEr½r²rarÀr‚rr¾r¿rrðr“rKr¦r©rTrXrÆrÄ)r.rlrórÉs r0r·zQuery._simple_statementas?€ØÔð $Ø#ˆGÔ à Œ>˜TÐ !Ð ! gÔ&6Ð !Ø Ð #Ô #ÝÔ9ØÔ% wÔ'7ñ(9ô(9ñ 9Ð #Ô #ð ˆ Œ �˜wÔ2×9Ò9Ñ;Ô;Ñ<Ô<Ñ<ˆ Œ å”JØ Ô # gÔ&?Ñ ?Ø Ô ð ð”]Ø”~ØÔ%ð  ð ð Ôð  ð ˆ ð%,Ô$;ˆ Ô!àÔ$ð 3ð 3ˆDØ+˜ Ô+¨TÐ2ˆIˆIà Œ?ð >Ø+˜ Ô+¨T¬_Ð=ˆIà Ô !ð ?Ø %ˆIÔ % wÔ'=Ð >Ð >ØÐr2có—t|j ¦«¦«}|jrP|j|jvrBt |j¦«}|jr|j}nd}| |j|fg¦«}|D]‡\}}||jvrŒ|j j }|�j|r|  |¦«}|  |dd¦«}tjtj |j¦«|¦«|_ŒˆdS)amApply single-table-inheritance filtering. For all distinct single-table-inheritance mappers represented in the columns clause of this query, as well as the "select from entity", add criterion to the WHERE clause of the given QueryContext such that only the appropriate subtypes are selected from the total results. NF)rÞr>r‚rYrr@rIr&r*rAÚ_single_table_criterionÚtraverserrÚand_ÚTrue_Ú_ifnoner)r.rlrzr±rSrMÚ single_crits r0r³z$Query._adjust_for_single_inheritances!€õ�TÔ-×4Ò4Ñ6Ô6Ñ7Ô7ˆà Ô $ð IàÔ(°Ô0HÐHÐHå˜4Ô3Ñ4Ô4ˆDØÔ$ð Øœ-��à�Ø—\’\ DÔ$<¸gÐ#FÐ"GÑHÔHˆFà#)ð ð Ñ ˆX�wؘ4Ô.Ð.Ð.ØØ"œ/ÔAˆKØÐ&Øð@Ø")×"2Ò"2°;Ñ"?Ô"?�Kà"×0Ò0°¸eÀUÑKÔK� Ý&)¤hÝ”I×%Ò% gÔ&9Ñ:Ô:¸Kñ'ô'�Ô#øð ð r2r=)TT)NNNNN)NFFr‹)NN)r¤)FFNFFr~)rž)ržN)¾reÚ __module__Ú __qualname__Ú__doc__rrrÈròrÉr$rÎrÍrwrÏrxryrÌrËrKrÊÚ frozensetrTrÛr_rÜrZrßrÝràrbr*rYr>r™rfr Ú immutabledictrvr¬r%rôr™r›r¦rorŒršÚ_path_registryrr7r®r‡r1r-r9rDrnrqr{r…r r‰rŽrr¡r£r¦rgr©r­r²r¶r¹rerÂrÅrÄrÁrÕr×rÙrærîrórürÿrrrGrr rrùrrúrrrrBr(rvrÚ PASSIVE_OFFr4r*rXr\rár`rrjrlrqrtrnr‚Ú_valuesr r‰rŒÚpending_deprecationrŽr“r–r‘r£r©r«r­r±Ú deprecatedr¶r½rõrfrÈr¿rÌrÏrÒr&rÖrÙrÛrÝrßrrçrórìrrrrrör8r<r>rIrArLrNrÀrSrVrXr[r_rcrfrhrmrtryrkr‚rorŠr}r�r“r•r˜r'r¦r»rñr¶r·r³r)r2r0r&r&>sï €€€€€ððð, ÐØÐØÐØ€LØ€JØ€JØ€IØ€IØ€GØ€IØ€IØ€IØ€GØ €FØ€OØ€JØ�‘”€JØÐØÐØ€NØ€JØÐØ€NØ"ÐØ€IØ€NØÐØÐØ€OØ€OØ/˜TÔ/Ñ1Ô1Ð1€I� Ø+˜Ô+Ñ-Ô-ÐØ ˆdÔ Ñ"Ô"€GØ$�$Ô$Ñ&Ô&€KØ€MØ€KØÐØ€OØ#ÐØ"€MØ ÐØ€HàÐð"ðH%ð%ð%ð%ð@9ð9ð9ð9ð8-ð-ð-ð>DðDðDð -1ð-1ð-1ð^DðDðDð /ð/ð/ð$ ð ð ð€[�]„]ð&ð&ñ„]ð&ð€[�]„]ð%ð%ñ„]ð%ð+Bð+Bð+BðZ!ð!ð!ð(ð(ð(ð  ð  ð  ðððñ„Xðð MðMðMðððð0ð0ð0ð#ð#ð#ð#ðððð  ð ð ð LðLðLððððð$AðAðAðAð+ð+ð+ð ð ð ð ð ð ðØØØØð ðððð(ððð ð ð ñ„Xð ð"ð"ð"ð"ð@9 ð9 ð9 ð9 ðv Cð Cð CðCðCðCðð )ð )ñ„Xð )ðEðEðEð€[�]„]ð )ð )ñ„]ð )ðð ð ñ„Xð ð*€[�]„]ð(ð(ñ„]ð(ð" ð ð ð€[�]„]ð!ð!ñ„]ð!ð4€[�]„]ð(ð(ñ„]ð(ð*ððñ„Xðð€[�]„]ð "ð "ñ„]ð "ð€[Ð,Ñ-Ô-à>Bð ð ð ñ.Ô-ð ðB€[�]„]ðC ðC ñ„]ðC ðJVBðVBðVBðxØÔ&Øð 4Mð4Mð4Mð4Mðl=6ð=6ð=6ð=6ð~€[�]„]ððñ„]ðð:€[�]„]ð "ð "ñ„]ð "ð€[�]„]ð'ð'ñ„]ð'ð&€[�]„]ð(ð(ñ„]ð(ð5Pð5Pð5Pð5Pðn€[�]„]ð *ð *ð *ñ„]ð *ð€[�]„]ððñ„]ðð2yðyðyðv€[�]„]ð'ð'ñ„]ð'ð€[�]„]ð;ð;ñ„]ð;ð6 ð ð ð€Gðððð€[�]„]ð%ð%ñ„]ð%ð4€[�]„]ð 9ð 9ñ„]ð 9ð€TÔØ ØFØ ñôð (ð(ñ ôð (ð+ð+ð+ð$*ð*ð*ð€[�]„]ð (ð (ñ„]ð (ðððð&€[�]„]ð@ð@ð@ñ„]ð@ð68ð8ð8ð8ð( 'ð 'ð 'ð€[�]„]ðHðHñ„]ðHð"€[�]„]Ø€T„_Ø ð 1ñôðDðDñôñ„]ðDð6€[�]„]ðØØ ØØð 8 ð8 ð8 ñ„]ð8 ðt€[�]„]ð$ð$ñ„]ð$ð(€[Ð(Ð*:Ñ;Ô;ð!,ð!,ñ<Ô;ð!,ðF&%ð&%ð&%ðP€[Ð(Ð*:Ñ;Ô;ð8ð8ñ<Ô;ð8ð6€[Ð(Ð*:Ñ;Ô;ð8ð8ñ<Ô;ð8ð4€[Ð(Ð*:Ñ;Ô;ð %ð %ñ<Ô;ð %ðD)ð)ð)ð %2ð%2ð%2ðN6ð6ð6ð6ð6ð6ð:ð:ð:ð4ð4ð4ð7ð7ð7ðc ðc ðc ðJ  ð ð ð2 ð ð ð€[Ð(Ð*:Ñ;Ô;ðXðXñ<Ô;ðXðtKðKðKðZf>ðf>ðf>ðP@8ð@8ð@8ðD`/ð`/ð`/ðD"ð"ð"ð€[Ð(Ñ)Ô)ð  ð  ñ*Ô)ð  ð€[Ð,Ñ-Ô-ð./ð./ñ.Ô-ð./ð`€[Ð,Ñ-Ô-ðp0ðp0ñ.Ô-ðp0ðd6ð6ð6ð:€[Ð(Ñ)Ô)ð+ ð+ ñ*Ô)ð+ ðZ€[Ð(Ñ)Ô)ððñ*Ô)ðð€[Ð(Ñ)Ô)ððñ*Ô)ðð€[Ð(Ñ)Ô)ð&ð&ñ*Ô)ð&ð>€[�]„]ð&ð&ñ„]ð&ð<€[�]„]ð&ð&ñ„]ð&ð*ððð$€[Ð,Ñ-Ô-ð$ð$ñ.Ô-ð$ð<ððð:"ð"ð"ðHððð@ððð64ð4ð4ð 4ð 4ð 4ðððð KðKðKð0ð0ð0ð ð ð ð ð= ð= ñ„Xð= ð~8ð8ð8ð8ð :ð:ð:ð:ð8ð  ð  ñ„Xð  ðð ð ñ„Xð ð( ð( ð( ðT8,ð8,ð8,ðtz"ðz"ðz"ðz"ðxG"ðG"ðG"ðG"ðR4ð4ð4ð4ðlGðGðGðRððð<"ð"ð"ð"ð"r2r&có$—eZdZed„¦«ZdS)r³có —|dvrdS|dkrd}d}n-|dkrdx}}n"|dkrd}d}ntjd|z¦«‚t||¬¦«S) Nr‹r¸TFr»Ú update_nowaitz"Unknown with_lockmode argument: %r)r¸r¹)rZr[r³)r.rµr¸r¹s r0r´zLockmodeArg.parse_legacy_query¥s‡€à �=Ð Ð Ø�4à �6Š>ˆ>؈D؈FˆFØ �XÒ Ð Ø!Ð !ˆD�6�6Ø �_Ò $Ð $؈F؈DˆDåÔ&Ø4°tÑ;ñôð õ ¨VÐ4Ñ4Ô4Ð4r2N)rerÓrÔÚ classmethodr´r)r2r0r³r³¤s-€€€€€Øð5ð5ñ„[ð5ð5ð5r2r³có—eZdZdZd„Zd„ZdS)r4z:Represent an entity column returned within a Query result.có—|tur]|d}t|tj¦«st |¦«rt }n$t|t ¦«rt}nt}t  |¦«S)Nr) r4r^r rûrr¨ÚBundleÚ _BundleEntityr€Úobjectrê)rìrVr°rLs r0rêz_QueryEntity.__new__½sy€Ø •,РРؘ!”WˆFݘf¥dÔ&7Ñ8Ô8ð $Õ=MØñ>ô>ð $õ$��ݘF¥FÑ+Ô+ð $Ý#��å#�Ý�~Š~˜cÑ"Ô"Ð"r2có€—|j |j¦«}|j ¦«|_|Sr=rèrÔs r0rîz_QueryEntity._cloneÊs3€Ø ŒN× "Ò " 4¤>Ñ 2Ô 2ˆØ”]×'Ò'Ñ)Ô)ˆŒ ؈r2N)rerÓrÔrÕrêrîr)r2r0r4r4ºs8€€€€€ØDÐDð #ð #ð #ðððððr2r4có|—eZdZdZd„ZdZdZd„Zd„Ze d„¦«Z e d„¦«Z d„Z d „Z d „Zd „Zd „Zd „ZdS)r¨z mapper/class/AliasedClass entitycó‚—|js||_|j |¦«d|_|g|_||_dSr•)r6r5r\r7r/rP)r.r~rLs r0r1z_MapperEntity.__init__ÓsG€ØÔ$ð )Ø$(ˆEÔ !Ø Œ×Ò˜tÑ$Ô$Ð$Ø%)ˆÔ"ؘˆŒ ؈Œ ˆ ˆ r2Tcó—|j|_||_|j|_|j|_|j|_|j|_||_|jr|jj |_ n|jj j |_ |jj |_dSr=)rArNrGr@Úwith_polymorphic_mappersÚ_with_polymorphicrÚ_polymorphic_discriminatorr¥rør†rMrerØr©r.rMrNs r0rJz_MapperEntity.setup_entityßsƒ€Ø”oˆŒ Ø.ˆÔØ"Ô-ˆŒØ (Ô 9ˆÔØ!)Ô!BˆÔØ*2Ô*AˆÔ'Ø#ˆÔØ Ô $ð ;Ø#Ô/Ô4ˆDÔ Ð à#œ{Ô1Ô:ˆDÔ ØÔ$Ô3ˆŒ ˆ ˆ r2cóD—|jrtd¦«‚|€| |j¦«dS|j ||¦«\}}||_||_||_| |jtj ||jj ¦«¦«dS)zÜReceive an update from a call to :meth:`_query.Query.with_polymorphic`. Note the newer style of using a free standing ``with_polymporphic()`` construct doesn't make use of this method. z6Can't use with_polymorphic() against an Aliased objectN) r@ÚNotImplementedErrorrqrAÚ_with_polymorphic_argsrërìrGrDrErFrH)r.r~r rGrÚmappersrks r0rz"_MapperEntity.set_with_polymorphicís½€ð Ô ð å%ØKñôð ð Ð !Ø × ,Ò ,¨T¬[Ñ 9Ô 9Ð 9Ø ˆFà œK×>Ò>Ø ˜Jñ ô ш�ð")ˆÔØ*8ˆÔ'à"ˆŒØ ×0Ò0Ø ŒKÝ Ô " 8¨T¬[Ô-LÑ MÔ Mñ ô ð ð ð r2có—|jjSr=)rArMr�s r0r÷z_MapperEntity.types €àŒ{Ô!Ð!r2có—|jSr=)r¥r�s r0rz'_MapperEntity.entity_zero_or_selectables €àÔÐr2có,—t|j|¦«Sr=)rr¥©r.rLs r0r"z_MapperEntity.corresponds_tos€Ý% dÔ&6¸Ñ?Ô?Ð?r2có:—|j |¦«dSr=)r5r\)r.r~Úsels r0rzz!_MapperEntity.adapt_to_selectables€Ø Œ×Ò˜tÑ$Ô$Ð$Ð$Ð$r2cóÒ—d}|js(|jr |j |jd¦«}n|j}|r%|jr| |j¦«}n |}n|j}|Sr=)r@r,rvrArNrfÚwrap)r.r~rlrSr^s r0Ú_get_entity_clausesz!_MapperEntity._get_entity_clausess~€àˆàÔ$ð +ØÔ*ð MØÔ5×9Ò9¸$¼+ÀtÑLÔL�øàÔ*ˆGà ð (ØÔ$ð Ø—l’l 5Ô#8Ñ9Ô9��à��àÔ'ˆCàˆ r2c óŒ—| ||¦«}|jr|r| |j¦«}n |s|j}|s0|jjr$t j|j|jj¦«}|j |ur|j }|j }ndx}}tj |j|||j||||j¬¦«}||jfS)N)rãräÚpolymorphic_discriminator)rúrSrùrAÚ_requires_row_aliasingrErFrGrHr6rßrärÚ_instance_processorrrìr†)r.r~rlr€rSrãräÚ _instances r0Ú row_processorz_MapperEntity.row_processor0sò€Ø×*Ò*¨5°'Ñ:Ô:ˆà Œ?ð &˜wð &Ø—l’l 7¤?Ñ3Ô3ˆGˆGØð &Ø”oˆGð ð ˜4œ;Ô=ð ÝÔ,Ø” ¤Ô!@ñôˆGð Ô  DÐ (Ð (Ø#Ô4ˆOØ#Ô1ˆMˆMà.2Ð 2ˆO˜måÔ/Ø ŒKØ Ø Ø ŒIØ Ø+Ø'Ø&*Ô&Eð  ñ  ô  ˆ ð˜$Ô*Ð*Ð*r2c ó†—| ||¦«}|xj|jfz c_|jdurP|jjrD|jj|_|r1| t j|j¦«¦«|_tj ||j||j ||j |j |j |j¬¦ « dS)NF)rBrãrü)rúr²rGr¿rAÚ adapt_listr r8rÚ_setup_entity_queryrr´rërßrì)r.r~rlrSs r0r¯z_MapperEntity.setup_contextSsÖ€Ø×*Ò*¨5°'Ñ:Ô:ˆð ˆ Œ ˜$œ/Ð+Ñ+ˆ Œ à Ô ˜uÐ $Ð $¨¬Ô)=Ð $Ø#œ{Ô3ˆGÔ ðð Ø#*×#5Ò#5Ý”L Ô!1Ñ2Ô2ñ$ô$�Ô õ Ô#Ø Ø ŒKØ Ø ŒIØ Ø Ô #Ø!Ô3Ø!Ô2Ø&*Ô&Eð ñ ô ð ð ð r2có*—t|j¦«Sr=)rørAr�s r0rtz_MapperEntity.__str__nó€Ý�4”;ÑÔÐr2N)rerÓrÔrÕr1r Úuse_id_for_hashrJrrgr÷rr"rzrúrr¯rtr)r2r0r¨r¨Ðs退€€€Ø*Ð*ðððð"Ðà€Oð 4ð 4ð 4ð ð ð ðBð"ð"ñ„Xð"ðð ð ñ„Xð ð@ð@ð@ð%ð%ð%ðððð(!+ð!+ð!+ðF ð ð ð6 ð ð ð ð r2r¨cód—eZdZdZdZ dZdZdZd„ZdZ dZ d„Z d„Z e d„¦«Zd„Zd „ZdS) rãaMA grouping of SQL expressions that are returned by a :class:`_query.Query` under one namespace. The :class:`.Bundle` essentially allows nesting of the tuple-based results returned by a column-oriented :class:`_query.Query` object. It also is extensible via simple subclassing, where the primary capability to override is that of how the set of expressions should be returned, allowing post-processing as well as custom return types, without involving ORM identity-mapped classes. .. versionadded:: 0.9.0 .. seealso:: :ref:`bundles` Fcóì—|x|_|_||_t¦«x|_|_|j d„|D¦«¦«| d|j¦«|_dS)aQConstruct a new :class:`.Bundle`. e.g.:: bn = Bundle("mybundle", MyClass.x, MyClass.y) for row in session.query(bn).filter( bn.c.x == 5).filter(bn.c.y == 4): print(row.mybundle.x, row.mybundle.y) :param name: name of the bundle. :param \*exprs: columns or SQL expressions comprising the bundle. :param single_entity=False: if True, rows for this :class:`.Bundle` can be returned as a "single entity" outside of any enclosing tuple in the same manner as a mapped entity. c3óFK—|]}t|d|j¦«|fV—ŒdS)r3N)rüÚ_label)r�r�s r0r=z"Bundle.__init__..¦sFèè€ð ð Ø7:�W�S˜% ¤Ñ ,Ô ,¨cÐ 2ð ð ð ð ð ð r2Ú single_entityN) rør Úexprsr#r<r�r»rpr )r.rør rws r0r1zBundle.__init__‘s„€ð$#'Ð&ˆŒ �D”K؈Œ Ý 0Ñ 2Ô 2Ð2ˆŒ�”Ø Œ ×Òð ð Ø>Cð ñ ô ñ ô ð ð ŸVšV O°TÔ5GÑHÔHˆÔÐÐr2Ncó‚—|j |j¦«}|j |j¦«|Sr=)rérêrër»)r.Úcloneds r0rîz Bundle._cloneÇs6€Ø”×'Ò'¨¬Ñ7Ô7ˆØŒ×Ò˜tœ}Ñ-Ô-Ð-؈ r2có.—tj|jddiŽS)NÚgroupF)r!Ú ClauseListr r�s r0rzBundle.__clause_element__Ìs€ÝÔ$°4´:Ð>¨5Ð>Ð>Ð>r2có4—| ¦«jSr=)rrÇr�s r0rÇzBundle.clausesÏs€à×&Ò&Ñ(Ô(Ô0Ð0r2có<—| ¦«}||_|S)z.proc..çs!ø€Ð<Ð<Ð<¨d   S¡ ¤ Ð<Ð<Ð.procæs)øø€Ø�;Ð<Ð<Ð<Ð<°eÐ<Ñ<Ô<Ñ=Ô=Ð =r2)r Úlightweight_named_tuple)r.r~rrðrrs ` @r0Úcreate_row_processorzBundle.create_row_processorÚs=øø€õÔ2°8¸VÑDÔDˆ ð >ð >ð >ð >ð >ð >ðˆ r2)rerÓrÔrÕr r¯rXr@r1r�r<rîrrgrÇrrr)r2r0rãrãrs¼€€€€€ððð&€Mð<ðÐà€IàÐðIðIðIð4€Gðð0 €AØ/ðððð ?ð?ð?ðð1ð1ñ„Xð1ððððððððr2rãcó�—eZdZdZdd„Zed„¦«Zed„¦«Zed„¦«Zd„Z ed„¦«Z d „Z d „Z d „Z d „Zd S)räFTcóJ—|j |¦«|x|_|_t |¦«|_|j|_g|_|r@|jD]8}t|t¦«rt||¦«Œ(t||¦«Œ9|jj |_ dSr=)r5r\ÚbundlerPr÷rør†r r^rãrär€r r )r.r~rÚsetup_entitiesrPs r0r1z_BundleEntity.__init__ïs¨€Ø Œ×Ò˜tÑ$Ô$Ð$Ø"(Ð(ˆŒ �d”iݘ‘L”LˆŒ Ø!œ;ˆÔ؈Œà ð .Øœ ð .ð .�ݘd¥FÑ+Ô+ð.Ý! $¨Ñ-Ô-Ð-Ð-å! $¨Ñ-Ô-Ð-Ð-à&*¤kÔ&?ˆÔ#Ð#Ð#r2có&—|j}|�|jSdSr=)r¥rA)r.r°s r0rAz_BundleEntity.mapperÿs€àÔ ˆØ Ð Ø”<Ð à�4r2cóR—g}|jD]}| |j¦«Œ|Sr=)r5Úextendr/)r.r/r;s r0r/z_BundleEntity.entitiess4€àˆØ”>ð *ð *ˆCØ �OŠO˜CœLÑ )Ô )Ð )Ð )؈r2có4—|jD]}|j}|�|cSŒdSr=)r5r¥©r.r;r°s r0r¥z_BundleEntity.entity_zeros5€à”>ð ð ˆCØ”OˆEØÐ Ø� � � ð!ð�4r2có—dSr‹r)rõs r0r"z_BundleEntity.corresponds_tos €ðˆur2có4—|jD]}|j}|�|cSŒdSr=)r5rr%s r0rz'_BundleEntity.entity_zero_or_selectables6€à”>ð ð ˆCØÔ1ˆEØÐ Ø� � � ð!ð�4r2cót—t||jd¬¦«}|jD]}| ||¦«ŒdS)NF)r )rärr5rz)r.r~r÷r<r;s r0rzz!_BundleEntity.adapt_to_selectable%sN€Ý ˜% ¤¸UÐ CÑ CÔ Cˆð ”>ð ,ð ,ˆCØ × #Ò # A sÑ +Ô +Ð +Ð +ð ,ð ,r2cóF—|jD]}| ||¦«ŒdSr=)r5rJ)r.rMrNr;s r0rJz_BundleEntity.setup_entity.s6€Ø”>ð 8ð 8ˆCØ × Ò ˜X Ñ 7Ô 7Ð 7Ð 7ð 8ð 8r2cóF—|jD]}| ||¦«ŒdSr=)r5r¯)r.r~rlr;s r0r¯z_BundleEntity.setup_context2s6€Ø”>ð .ð .ˆCØ × Ò ˜e WÑ -Ô -Ð -Ð -ð .ð .r2có�‡‡‡—tˆˆˆfd„|jD¦«Ž\}}|j ‰||¦«}||jfS)Ncó>•—g|]}| ‰‰‰¦«‘ŒSr))r)r�r;rlr~r€s €€€r0rƒz/_BundleEntity.row_processor..8s;ø€ðððàð×!Ò! %¨°&Ñ9Ô9ðððr2)Úzipr5rrr†)r.r~rlr€rrðrs ``` r0rz_BundleEntity.row_processor6snøøø€Ýððððððàœ>ðñôð ‰ ˆˆvðŒ{×/Ò/°°u¸fÑEÔEˆà�TÔ%Ð%Ð%r2Nr~)rerÓrÔrr1rgrAr/r¥r"rrzrJr¯rr)r2r0räräìs耀€€€Ø€Oð@ð@ð@ð@ð ððñ„Xððððñ„Xðð ððñ„Xððððð ððñ„Xðð,ð,ð,ð8ð8ð8ð.ð.ð.ð &ð &ð &ð &ð &r2räcóX—eZdZdZd d„ZdZed„¦«Zd„Zd„Z d„Z d „Z d „Z d „Z dS) r€zColumn/expression based entity.Ncó>‡ —||_||_d}d}t|tj¦«r;tjd¦«t j|¦«}|j|_ d}d}d}n„t|tj tj f¦«r^t|dd¦«}|�d}|j|_ | ¦«}d}t|t"¦«rt%||¦«dSt|t j¦«sLt)|d¦«r$|jD]}||urnt-|||¬¦«ŒdSt/jd|›d�¦«‚|st|d d¦«|_ d}|jx|_}|j |_|js+t|d d¦«s| |j ¦«}|j |¦«||_ tC¦«|_"tG|j$¦«|_%tC|j%¦«Š |sG||_&|r|g|_'|j(|_(ng|_'d|_(tC|j'¦«|_)dSd „tUj+|d¬ ¦«D¦«} tj,d „| D¦«¦«|_'tCˆ fd„| D¦«¦«|_)|j'r%|j'd|_&|j&j(|_(dS|j�|j|_&d|_(dSd|_&d|_(dS)NTFz¢Plain string expression passed to Query() should be explicitly declared using literal_column(); automatic coercion of this value will be removed in SQLAlchemy 1.4rýÚ_select_iterable)Ú namespacez9SQL expression, column, or mapped entity expected - got 'rbr3Ú is_literalcó$—g|] }d|jv¯ |‘ŒS©rsr’©r�r“s r0rƒz*_ColumnEntity.__init__..œs4€ðððàð" TÔ%6Ð6Ð6ð ð7Ð6Ð6r2)Úinclude_scalar_selectscó:—g|]}d|jv¯ |jd‘ŒSr4r’r5s r0rƒz*_ColumnEntity.__init__..¥s8€ðððàØ%¨Ô):Ð:Ð:ðÔ% nÔ5à:Ð:Ð:r2cóp•—g|]2}d|jv¯ ‰ |j¦«¯%|jd‘Œ3Sr4)ruÚ intersectionÚ _from_objects)r�r“Ú actual_fromss €r0rƒz*_ColumnEntity.__init__..­sRø€ðððàØ%¨Ô):Ð:Ð:Ø$×1Ò1°$Ô2DÑEÔEð;ðÔ% nÔ5à:Ð:Ð:r2r)-rPr1r^r rûÚwarn_deprecatedrr™rør†rrrrùrür3Ú_query_clause_elementrãräÚ ColumnElementrWr0r€rZr´r÷Úhashablerr rr5r\r‡rÞr²rFr:r;r¥r/rAÚ_from_entitiesrEÚsurface_column_elementsÚ unique_list) r.r~r‡r1Úsearch_entitiesÚ check_columnÚ_entityr<Útype_Ú all_elementsr;s @r0r1z_ColumnEntity.__init__Fs–ø€ØˆŒ Ø"ˆŒØˆØˆ å �f�dÔ/Ñ 0Ô 0ð Ý Ô ð!ñ ô ð õ Ô'¨Ñ/Ô/ˆFØ%œ{ˆDÔ Ø#ˆO؈L؈GˆGÝ Ø •ZÔ2µJÔ4MÐNñ ô ð õ˜f o°tÑ<Ô<ˆGØÐ"Ø"'�Ø%œzˆDÔ Ø×1Ò1Ñ3Ô3ˆF؈Lݘ&¥&Ñ)Ô)ð ݘe VÑ,Ô,Ð,Ø�å˜&¥#Ô"3Ñ4Ô4ð #Ý�vÐ1Ñ2Ô2ð ð Ô0ðð�AؘF�{�{ؘÝ! %¨°fÐ=Ñ=Ô=Ð=Ð=à�FåÔ,Ð,à)/¨¨ð2ñôð ðð #Ý& v¨u°dÑ;Ô;ˆDÔ Ø"ˆOà"œKÐ'ˆŒ �EØ#(¤>Ð1ˆÔðŒ}ð 4¥W¨V°\À5Ñ%IÔ%Ið 4Ø—\’\ $Ô"2Ñ3Ô3ˆFà Œ×Ò˜tÑ$Ô$Ð$àˆŒ Ý‘U”UˆŒ õ! Ô!5Ñ6Ô6ˆÔݘ4Ô,Ñ-Ô-ˆ àð* #Ø&ˆDÔ Øð #Ø!(  �” Ø%œn�” � à "�” Ø"�” Ý"% d¤mÑ"4Ô"4ˆDÔ Ð Ð ððå$Ô<ذ5ðñôðñôˆLõ!Ô,ððà ,ðñôñôˆDŒMõ#&ððððà ,ðñôñ#ô#ˆDÔ ðŒ}ð #Ø#'¤=°Ô#3�Ô Ø"Ô.Ô5�” � � Ø”Ð+Ø#'¤>�Ô Ø"�” � � à#'�Ô Ø"�” � � r2FcóJ—|j�|jS|jr |jdSdS)Nr)r¥r;r�s r0rz'_ColumnEntity.entity_zero_or_selectableÀs2€à Ô Ð 'ØÔ#Ð #Ø Ô ð ØÔ$ QÔ'Ð 'à�4r2cóž—t|| |j¦«¦«}|j|_|j|_|j|_dSr=)r€Úcorresponding_columnr‡r†r¥r/)r.r~r÷r<s r0rzz!_ColumnEntity.adapt_to_selectableÉsB€Ý ˜% ×!9Ò!9¸$¼+Ñ!FÔ!FÑ GÔ GˆØÔ(ˆŒ ØÔ(ˆŒ Ø”]ˆŒ ˆ ˆ r2cóÔ—d|jvr |j|_t|j¦« |jj¦«r!|j |j¦«dSdS)NrG)rërGrÞr;r9r:r²Úaddrís r0rJz_ColumnEntity.setup_entityÏsn€Ø ˜tœ}Ð ,Ð ,Ø&Ô1ˆDŒOå ˆtÔ Ñ !Ô !× .Ò .Ø Ô Ô -ñ ô ð 0ð ŒJ�NŠN˜8Ô.Ñ /Ô /Ð /Ð /Ð /ð 0ð 0r2có¢—|j€dSt|¦«r ||juSt|j¦« o| |j¦«Sr‹)r¥rr)rõs r0r"z_ColumnEntity.corresponds_toØsd€Ø Ô Ð #Ø�5Ý ˜vÑ &Ô &ð 9à˜TÔ-Ð-Ð -å(ØÔ ñôðð9à×&Ò& tÔ'7Ñ8Ô8ð 9r2có—d|f|jvr|jd|f}n| |jdd¦«}|jr| ¦«}|jr|jj|}| |¦«}||jfS)NÚ fetch_columnFT) rrr‡ruÚ _deannotaterSr�Ú_getterr†)r.r~rlr€r‡Úgetters r0rz_ColumnEntity.row_processorãs˜€Ø ˜DÐ ! WÔ%7Ð 7Ð 7ØÔ'¨¸Ð(>Ô?ˆFˆFà×(Ò(¨¬°e¸TÑBÔBˆFà Ô ð *ð×'Ò'Ñ)Ô)ˆFà Œ?ð 5Ø”_Ô,¨VÔ4ˆFà—’ Ñ'Ô'ˆØ�tÔ'Ð'Ð'r2có—| |jdd¦«}|jr| ¦«}|xjt |j¦«z c_|j |¦«||jd|f<dS)NFTrO) rr‡rurPr²rar´r\r)r.r~rlr‡s r0r¯z_ColumnEntity.setup_contextôs‚€Ø×$Ò$ T¤[°%¸Ñ>Ô>ˆà Ô ð *ð×'Ò'Ñ)Ô)ˆFàˆ Œ �˜tœzÑ*Ô*Ñ*ˆ Œ ØÔ×&Ò& vÑ.Ô.Ð.à5;ˆÔ˜N¨DÐ1Ñ2Ð2Ð2r2có*—t|j¦«Sr=)rør‡r�s r0rtz_ColumnEntity.__str__rr2r=)rerÓrÔrÕr1r rgrrzrJr"rr¯rtr)r2r0r€r€Cs®€€€€€Ø)Ð)ðv#ðv#ðv#ðv#ðp#Ðà ððñ„Xðð#ð#ð#ð 0ð0ð0ð 9ð 9ð 9ð(ð(ð(ð" <ð <ð <ð ð ð ð ð r2r€có—eZdZdZd„ZdS)r')rµrSr²Ú for_updater~r+r\ráÚinvoke_all_eagersrârär´r¿rÆrÀr°Úpropagate_optionsrrór±rr¿rðrKÚrunidÚpartialsÚpost_load_pathsråcó—|j�ct|jtj¦«r7|jjs+|jjs|j ¦«|_n8|j|_n+d|_|j|_ |j |_ |j |_ d|_d|_d|_d|_||_|j|_|j|_|j|_|j|_|j|_|j|_g|_g|_g|_ i|_!g|_"tGd„|j$D¦«¦«|_%|j& '¦«|_(|j�|j)|_*dSd|_*dS)NFr)c3ó(K—|] }|j¯ |V—ŒdSr=)Úpropagate_to_loaders)r�r‚s r0r=z(QueryContext.__init__..Fs>èè€ð% ð% بaÔ.Dð% Ø ð% ð% ð% ð% ð% ð% r2)+rÊr^r!r_Ú_textualrjÚ apply_labelsrórbr±rÉrrÎr¿rµrSr²rVr~r+rZr\rÛrár_rWrÜrârÝrär´r¿rÆrÀr°rÞr›rXr™r?rràrå)r.r~s r0r1zQueryContext.__init__%sˆ€à Ô Ð 'å˜5Ô+­ZÔ-BÑCÔCð 2àÔ(Ô1ð 2ðÔ(Ô3ð 2ð "'Ô!1×!>Ò!>Ñ!@Ô!@�”�à!&Ô!1�”�à!ˆDŒNØ$œˆDÔ Ø$Ô/ˆDÔ Ø!œOˆDŒMà',ˆÔ$؈Œ ؈Œ ؈ŒØˆŒ Ø”}ˆŒ ØÔ)ˆŒØ!&Ô!9ˆÔØ!&Ô!9ˆÔØ"Ô1ˆÔØ"Ô1ˆÔØ!ˆÔØ!#ˆÔØ ˆÔØˆÔØ"$ˆÔÝ!$ð% ð% ØÔ*ð% ñ% ô% ñ" ô" ˆÔð Ô+×0Ò0Ñ2Ô2ˆŒØ Ô Ð )Ø"'Ô"?ˆDÔ Ð Ð à"&ˆDÔ Ð Ð r2N)rerÓrÔÚ __slots__r1r)r2r0r'r's*€€€€€ð€Ið>('ð('ð('ð('ð('r2r'có—eZdZd„Zd„ZdS)Ú AliasOptioncó—||_dS)a"Return a :class:`.MapperOption` that will indicate to the :class:`_query.Query` that the main table has been aliased. This is a seldom-used option to suit the very rare case that :func:`.contains_eager` is being used in conjunction with a user-defined SELECT statement that aliases the parent table. E.g.:: # define an aliased UNION called 'ulist' ulist = users.select(users.c.user_id==7).\ union(users.select(users.c.user_id>7)).\ alias('ulist') # add on an eager load of "addresses" statement = ulist.outerjoin(addresses).\ select().apply_labels() # create query, indicating "ulist" will be an # alias for the main table, "addresses" # property should be eager loaded query = session.query(User).options( contains_alias(ulist), contains_eager(User.addresses)) # then get results via the statement results = query.from_statement(statement).all() :param alias: is the string name of an alias, or a :class:`_expression.Alias` object representing the alias. N)r`)r.r`s r0r1zAliasOption.__init__Qs€ðBˆŒ ˆ ˆ r2cóè—t|jtj¦«r2| ¦«j |j¦«}n|j}t j|¦«|_dSr=) r^r`r rûr£rCrErFrf)r.r~r`s r0r�zAliasOption.process_queryts_€Ý �d”j¥$Ô"3Ñ 4Ô 4ð Ø×&Ò&Ñ(Ô(Ô;×AÒAÀ$Ä*ÑMÔMˆEˆEà”JˆEÝ (Ô 6°uÑ =Ô =ˆÔÐÐr2N)rerÓrÔr1r�r)r2r0rcrcPs3€€€€€ð!ð!ð!ðF>ð>ð>ð>ð>r2rcN);rÕÚ itertoolsrÚrrrarrr r Úbaser r rrrrÚ path_registryrr rrrrrrrrrZrrrrr!rEr"Úsql.baser#Úsql.expressionr$Úsql.selectabler%Ú__all__ÚrootrØÚ_self_inspectsÚ class_loggerrår&r³r4r¨rãrär€r'Ú MapperOptionrcr)r2r0úrrslðð ð ðÐÐÐÐÐàÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØ$Ð$Ð$Ð$Ð$Ð$ØÐÐÐÐÐØ#Ð#Ð#Ð#Ð#Ð#Ø"Ð"Ð"Ð"Ð"Ð"ØÐÐÐÐÐØ Ð Ð Ð Ð Ð Ø'Ð'Ð'Ð'Ð'Ð'Ø(Ð(Ð(Ð(Ð(Ð(ØÐÐÐÐÐØÐÐÐÐÐØ"Ð"Ð"Ð"Ð"Ð"ØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØ"Ð"Ð"Ð"Ð"Ð"ØÐÐÐÐÐØ'Ð'Ð'Ð'Ð'Ð'Ø/Ð/Ð/Ð/Ð/Ð/Ø)Ð)Ð)Ð)Ð)Ð)à .Ð .Ð .€ðÔ"€ð ÔØÔðaAðaAðaAðaAðaAˆFñaAôaAñÔñÔðaAðHC5ð5ð5ð5ð5�,ñ5ô5ð5ð,ðððð�6ñôðð,_ ð_ ð_ ð_ ð_ �Lñ_ ô_ ð_ ðD Ôðvðvðvðvðvˆ^ñvôvñÔðvðrT&ðT&ðT&ðT&ðT&�LñT&ôT&ðT&ðn ð ð ð ð �Lñ ô ð ðDH'ðH'ðH'ðH'ðH'�6ñH'ôH'ðH'ðV)>ð)>ð)>ð)>ð)>�*Ô)ñ)>ô)>ð)>ð)>ð)>r2