idnddlmZddlmZddlmZddlmZddlmZ ddl m Z ddl m Z dd lmZd ZGd d e Zeed dZGdde ZGddeZGddeZdS))ext)util)schema) _generative)Insert) ClauseElement)alias)public_factory)rinsertcneZdZdZejdZe ddZe ddZ dS)ra PostgreSQL-specific implementation of INSERT. Adds methods for PG-specific syntaxes such as ON CONFLICT. The :class:`_postgresql.Insert` object is created using the :func:`sqlalchemy.dialects.postgresql.insert` function. .. versionadded:: 1.1 c8t|jdjS)aProvide the ``excluded`` namespace for an ON CONFLICT statement PG's ON CONFLICT clause allows reference to the row that would be inserted, known as ``excluded``. This attribute provides all columns in this row to be referenceable. .. seealso:: :ref:`postgresql_insert_on_conflict` - example of how to use :attr:`_expression.Insert.excluded` excluded)name)r tablecolumns)selfs W/opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/dml.pyrzInsert.excluded!sTZj11199Nc6t||||||_|S)a Specifies a DO UPDATE SET action for ON CONFLICT clause. Either the ``constraint`` or ``index_elements`` argument is required, but only one of these can be specified. :param constraint: The name of a unique or exclusion constraint on the table, or the constraint object itself if it has a .name attribute. :param index_elements: A sequence consisting of string column names, :class:`_schema.Column` objects, or other column expression objects that will be used to infer a target index. :param index_where: Additional WHERE criterion that can be used to infer a conditional target index. :param set\_: Required argument. A dictionary or other mapping object with column names as keys and expressions or literals as values, specifying the ``SET`` actions to take. If the target :class:`_schema.Column` specifies a ". key" attribute distinct from the column name, that key should be used. .. warning:: This dictionary does **not** take into account Python-specified default UPDATE values or generation functions, e.g. those specified using :paramref:`_schema.Column.onupdate`. These values will not be exercised for an ON CONFLICT style of UPDATE, unless they are manually specified in the :paramref:`.Insert.on_conflict_do_update.set_` dictionary. :param where: Optional argument. If present, can be a literal SQL string or an acceptable expression for a ``WHERE`` clause that restricts the rows affected by ``DO UPDATE SET``. Rows not meeting the ``WHERE`` condition will not be updated (effectively a ``DO NOTHING`` for those rows). .. versionadded:: 1.1 .. seealso:: :ref:`postgresql_insert_on_conflict` )OnConflictDoUpdate_post_values_clause)r constraintindex_elements index_whereset_wheres ron_conflict_do_updatezInsert.on_conflict_do_update1s)t$6  T5$ $   rc2t||||_|S)a) Specifies a DO NOTHING action for ON CONFLICT clause. The ``constraint`` and ``index_elements`` arguments are optional, but only one of these can be specified. :param constraint: The name of a unique or exclusion constraint on the table, or the constraint object itself if it has a .name attribute. :param index_elements: A sequence consisting of string column names, :class:`_schema.Column` objects, or other column expression objects that will be used to infer a target index. :param index_where: Additional WHERE criterion that can be used to infer a conditional target index. .. versionadded:: 1.1 .. seealso:: :ref:`postgresql_insert_on_conflict` )OnConflictDoNothingrrrrrs ron_conflict_do_nothingzInsert.on_conflict_do_nothingps$<$7  $ $   rNNNNNNNN) __name__ __module__ __qualname____doc__rmemoized_propertyrrrr"rrrrs    : : :  <<<[<|@D   [   rrz.dialects.postgresql.insertz.dialects.postgresql.InsertceZdZddZdS)OnConflictClauseNc|]t|tjsCt|tjtjt jfrt|dp|}||tdt|tjr||_ d|_ d|_ nt|tjr(|j }|jdd}nPt|t jr|j}|j}n'|j}|jdd}|d|_ ||_ ||_ dS|dx|_ x|_ |_ dSdS)Nrz8'constraint' and 'index_elements' are mutually exclusive postgresqlr) isinstancer string_typesrIndex ConstraintrExcludeConstraintgetattr ValueErrorconstraint_targetinferred_target_elementsinferred_target_whereclause expressionsdialect_optionsgetrrr!s r__init__zOnConflictClause.__init__s  !j$*;<< Gv0#2GHBB G%Z88FJ  !) N*d&788 )3&04-3700J 55 !+!7(8FJJ J(=>> !+!3(. !+!3(8FJJ   %%)D ",:D )/:D , , ,  48 8D " 8-000 rr$)r%r&r'r<r*rrr,r,s((8(8(8(8(8(8rr,ceZdZdZdS)r r"N)r%r&r'__visit_name__r*rrr r s-NNNrr c.eZdZdZ dfd ZxZS)rrNc8tt|||||j|jt dt |tr|st dd|D|_ ||_ dS)N)rrrzVEither constraint or index_elements, but not both, must be specified unless DO NOTHINGz,set parameter must be a non-empty dictionarycg|] \}}||f Sr*r*).0keyvalues r z/OnConflictDoUpdate.__init__..s-% % % 'S%S%L% % % r) superrr<r7r6r5r/dictitemsupdate_values_to_setupdate_whereclause)rrrrrr __class__s rr<zOnConflictDoUpdate.__init__s  $''00!)# 1     ) 1&.D  $%% MT MKLL L% % +/::<<% % % !#(rr#)r%r&r'r>r< __classcell__)rKs@rrrsS,N  ((((((((((rrN)rrsqlrsql.basersql.dmlrStandardInsert sql.elementsr sql.expressionr util.langhelpersr __all__r r,r rr*rrrVsx######//////))))))######...... |||||^|||~  )+H   )8)8)8)8)8})8)8)8X.....*...((((()(((((r