관리-도구
편집 파일: loading.cpython-38.pyc
U -?�f�� � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z dd lm Z dd lmZ ddlmZ ddlm Z dd lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl!m"Z" ddl#m$Z$ ddl#m%Z% dd l#m&Z& dd!l'm(Z( ddl'mZ) dd"l*m+Z+ dd#l*m,Z, dd$l*m-Z- dd%lm.Z. e�r>dd&l/m0Z0 dd'lm1Z1 dd(l2m3Z3 dd)l4m5Z5 dd*l6m7Z7 dd+l8m9Z9 dd,l:m;Z; dd-l<m=Z= dd.l>m?Z? dd/l#m@Z@ dd0l'mAZA e d1ed2�ZBe d3eCd2�ZDe�E� ZFeeGeeeGef f ZHd4d5d6d7�d8d9�ZIe�Jd:�dzd<d=��ZKejLd>d?d@�e�Jd:�d{dAdBdCdDdE�dFdG���ZMdHdIdJdKdLdM�dNdO�ZNdPdPdPdPdQej.ej.dQdQdR� dHdSdTdUdVdWdXdCdYdZdCdCd[�d\d]�ZOdPdPdPdPdPdQej.ej.dQdQd^� dHdSd_dUdVdWdXd`dCdYdZdCdCda� dbdc�ZPd|ddde�ZQd}dfdg�ZRdhdi� ZSd~djdk�ZTdldm� ZUdndo� ZVdpdq� ZWdrds� ZXdtdu� ZYG dvdw� dw�ZZdxdy� Z[dPS )z�private module containing functions used to convert database rows into object instances and associated state. the functions here are called primarily by Query, Mapper, as well as some of the attribute loading strategies. � )�annotations)�Any)�Dict)�Iterable)�List)�Mapping)�Optional)�Sequence)�Tuple)� TYPE_CHECKING)�TypeVar)�Union� )� attributes)�exc)� path_registry)�_DEFER_FOR_STATE)�_RAISE_FOR_STATE)�_SET_DEFERRED_EXPIRED)�PassiveFlag)� FromStatement)�ORMCompileState)�QueryContext)� _none_set)� state_str� )�util)�result_tuple)�ChunkedIteratorResult)�FrozenResult)�SimpleResultMetaData)�select)�ForUpdateArg)�LABEL_STYLE_TABLENAME_PLUS_COL)�SelectState)� EMPTY_DICT)�_IdentityKeyType)�LoaderCallableStatus)� ORMOption)�Mapper)�Query)�Session)� InstanceState)�CursorResult)�_ExecuteOptions)�Result)�Select�_T)�bound�_OzCursorResult[Any]r zResult[Any])�cursor�context�returnc s� t � �_�jrd��jj�_n d�i �_�j}|j}�jj oVt|j �dkoV|j d j �zFtt��fdd��jj D �� �\�}}�j r��js��jr�t�d��W n0 tk r� t�� � ��� W 5 Q R X Y nX dd � � ddd �dd��� ��fd d��jj D �}t|||d�}�����fdd�}�j�dd��rLt|d����fdd�}t||���jjd�} | j�t|�d��| _�jj�r�dd� } d| f| _ �j �r�| � �j � | S )a� Return a :class:`.Result` given an ORM query context. :param cursor: a :class:`.CursorResult`, generated by a statement which came from :class:`.ORMCompileState` :param context: a :class:`.QueryContext` object :return: a :class:`.Result` object representing ORM results .. versionchanged:: 1.4 The instances() function now uses :class:`.Result` objects and has an all new interface. FTr r c s g | ]}|� � ���qS � )Z row_processor)�.0�query_entity)r5 r4 r7 �F/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/orm/loading.py� <listcomp>q s �zinstances.<locals>.<listcomp>z�Can't use yield_per with eager loaders that require uniquing or row buffering, e.g. joinedload() against collections or subqueryload(). Consider the selectinload() strategy for better flexibility in loading objects.c S s t �d��d S )Nz@Can't use the ORM yield_per feature in conjunction with unique()��sa_exc�InvalidRequestError)�entryr7 r7 r: � _no_unique� s �zinstances.<locals>._no_unique��legacy� uncertainc s6 |s��fdd�}|S �st S d� � fdd�}|S d S )Nc s@ �rz t | �W S Y nX t�d� �d�r0dnd� d���d S )Nz=Can't apply uniqueness to row tuple containing value of type z; z the values returned appear to bezthis datatype producesz non-hashable values)�hashr= r>