o
    y¬´\w
  ã                   @   sz   d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ dZG dd	„ d	eƒZeed
ƒZG dd„ deƒZdS )é   )Úutil)Ú_generative)ÚInsert)ÚClauseElement)Úalias)Úpublic_factory)r   Úinsertc                   @   s6   e Zd ZdZedd„ ƒZejdd„ ƒZe	dd„ ƒZ
dS )	r   z˜MySQL-specific implementation of INSERT.

    Adds methods for MySQL-specific syntaxes such as ON DUPLICATE KEY UPDATE.

    .. versionadded:: 1.2

    c                 C   s   | j jS )a¯  Provide the "inserted" namespace for an ON DUPLICATE KEY UPDATE statement

        MySQL's ON DUPLICATE KEY UPDATE clause allows reference to the row
        that would be inserted, via a special function called ``VALUES()``.
        This attribute provides all columns in this row to be referenceable
        such that they will render within a ``VALUES()`` function inside the
        ON DUPLICATE KEY UPDATE clause.    The attribute is named ``.inserted``
        so as not to conflict with the existing :meth:`.Insert.values` method.

        .. seealso::

            :ref:`mysql_insert_on_duplicate_key_update` - example of how
            to use :attr:`.Insert.inserted`

        )Úinserted_aliasÚcolumns©Úself© r   úO/var/www/html/env/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/dml.pyÚinserted   s   zInsert.insertedc                 C   s   t | jdd�S )Nr   )Úname)r   Útabler   r   r   r   r	   '   s   zInsert.inserted_aliasc                 K   s   t | ddƒ}t||ƒ| _| S )a¯  
        Specifies the ON DUPLICATE KEY UPDATE clause.

        :param \**kw:  Column keys linked to UPDATE values.  The
         values may be any SQL expression or supported literal Python
         values.

        .. warning:: This dictionary does **not** take into account
           Python-specified default UPDATE values or generation functions,
           e.g. those specified using :paramref:`.Column.onupdate`.
           These values will not be exercised for an ON DUPLICATE KEY UPDATE
           style of UPDATE, unless values are manually specified here.

        .. versionadded:: 1.2

        .. seealso::

            :ref:`mysql_insert_on_duplicate_key_update`

        r	   N)ÚgetattrÚOnDuplicateClauseÚ_post_values_clause)r   Úkwr	   r   r   r   Úon_duplicate_key_update+   s   zInsert.on_duplicate_key_updateN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úpropertyr   r   Úmemoized_propertyr	   r   r   r   r   r   r   r      s    

r   z.dialects.mysql.insertc                   @   s   e Zd ZdZdd„ ZdS )r   r   c                 C   s&   || _ |r
t|tƒstdƒ‚|| _d S )Nz/update parameter must be a non-empty dictionary)r	   Ú
isinstanceÚdictÚ
ValueErrorÚupdate)r   r	   r    r   r   r   Ú__init__L   s   
zOnDuplicateClause.__init__N)r   r   r   Ú__visit_name__r!   r   r   r   r   r   I   s    r   N)Ú r   Úsql.baser   Úsql.dmlr   ÚStandardInsertÚsql.elementsr   Úsql.expressionr   Úutil.langhelpersr   Ú__all__r   r   r   r   r   r   Ú<module>   s    
;