XylotrechusZ
�
Ȓ�g� � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlm Z dd lm
Z dd
lmZ ddlm
Z
ddlmZ d
d lm
Z d
dlmZ d
dlmZ d
dlmZ d
dlmZ d
dlmZ d
dlmZ d
dlmZ d0d�Zd� Zd� Zd� Zd� Z d� Z!ddddd�d�Z"dddd�d �Z#d!� Z$d"� Z%d#dd#d$�d%�Z&d#ddd&�d'�Z'd(� Z(d)� Z)d*� Z*d+� Z+d,� Z,d-� Z-d.� Z.d/� Z/y)1z�private module containing functions used to emit INSERT, UPDATE
and DELETE statements on behalf of a :class:`_orm.Mapper` and its descending
mappers.
The functions here are called only by the unit of work functions
in unitofwork.py.
� )�annotations)�chain)�groupby)�zip_longestN� )�
attributes)�exc)�loading)�sync)� state_str� )�future)�sql)�util)�cursor)� operators)�BooleanClauseList)�LABEL_STYLE_TABLENAME_PLUS_COLFc � � |s.| j s"t | |� D ] }t | |g|d�� � yg }g }t | ||� D ]: \ }}}} }
}}|
s|r|j |||| |f� �&|j |||| f� �< | j
j
� D ]K \ }
}|
|j vr�t |
|� }t ||
|� }t | |||
|� t | |||
|� �M t | |t d� |D � d� |D � � � y)a; Issue ``INSERT`` and/or ``UPDATE`` statements for a list
of objects.
This is called within the context of a UOWTransaction during a
flush operation, given a list of states to be flushed. The
base mapper in an inheritance hierarchy handles the inserts/
updates for all descendant mappers.
T)�singleNc 3 �4 K � | ] \ }}}}||||d f�� � y�w)FN� )�.0�state�
state_dict�mapper�
connections �K/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/orm/persistence.py� <genexpr>zsave_obj.<locals>.<genexpr>i s, � �� �
�?O�;�U�J��
� �
�F�J��>�?O�s �c 3 �6 K � | ] \ }}}}}||||d f�� � y�w)TNr )r r r r r �update_version_ids r r zsave_obj.<locals>.<genexpr>m s9 � �� �
� &�
�����%�
�
�F�J��=� &�s �)�batch�_sort_states�save_obj�_organize_states_for_save�append�_sorted_tables�items�
_pks_by_table�_collect_insert_commands�_collect_update_commands�_emit_update_statements�_emit_insert_statements� _finalize_insert_update_commandsr )�base_mapper�states�uowtransactionr r �states_to_update�states_to_insert�dict_r r �has_identity�
row_switchr! �table�insert�updates r r$ r$ ( s] � � �+�+�+�!�+�v�6�E��[�5�'�>�$�G� 7������
#�;��� G� �
�
�������:��#�#���v�z�3D�E�
�
�#�#�U�E�6�:�$F�G�
H� %�3�3�9�9�;�
��v���,�,�,��)�%�1A�B��)��E�#3�
�� ������
� ������
�# <�2 %���
�
�?O�
�
� &�
�
�� c �� ��� t t | ||� � }| j j � D ]>