σ ΓΜ4]c@sρddlmZddlmZddlmZddlmZddlmZ ddl m Z ddl m Z dd lmZdZd e fd „ƒYZeed ƒZde fd„ƒYZdefd„ƒYZdefd„ƒYZdS(i(texti(tutil(tschema(t _generative(tInsert(t ClauseElement(talias(tpublic_factoryRtinsertcBsVeZdZejd„ƒZedddddd„ƒZedddd„ƒZ RS(sŽPostgreSQL-specific implementation of INSERT. Adds methods for PG-specific syntaxes such as ON CONFLICT. .. versionadded:: 1.1 cCst|jddƒjS(sProvide 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:`.Insert.excluded` tnametexcluded(Rttabletcolumns(tself((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyR scCst|||||ƒ|_|S(s 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:`.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:`.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:`.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` (tOnConflictDoUpdatet_post_values_clause(R t constrainttindex_elementst index_wheretset_twhere((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyton_conflict_do_update.s9cCst|||ƒ|_|S(s" 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:`.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` (tOnConflictDoNothingR(R RRR((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyton_conflict_do_nothinglsN( t__name__t __module__t__doc__Rtmemoized_propertyR RtNoneRR(((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyRs7s.dialects.postgresql.inserttOnConflictClausecBseZdddd„ZRS(cCsƒ|dk r[t|tjƒ r[t|tjtjtjfƒr[t |dƒpR|}q[n|dk r/|dk r‚t dƒ‚nt|tjƒr²||_ d|_ d|_ q/t|tjƒrζ|j}|jdjdƒ}q/t|tjƒr |j}|j}q/|j}|jdjdƒ}n|dk rYd|_ ||_ ||_ n&|dkrd|_ |_ |_ ndS(NR s8'constraint' and 'index_elements' are mutually exclusivet postgresqlR(Rt isinstanceRt string_typesRtIndext ConstraintRtExcludeConstrainttgetattrt ValueErrortconstraint_targettinferred_target_elementstinferred_target_whereclauset expressionstdialect_optionstgetR R(R RRR((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyt__init__”s:                    N(RRRR,(((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyR“sRcBseZdZRS(R(RRt__visit_name__(((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyRΏsRcBs&eZdZdddddd„ZRS(RcCs³tt|ƒjd|d|d|ƒ|jdkrR|jdkrRtdƒ‚nt|tƒ si| rxtdƒ‚ng|j ƒD]\}}||f^q…|_ ||_ dS(NRRRsVEither constraint or index_elements, but not both, must be specified unless DO NOTHINGs,set parameter must be a non-empty dictionary( tsuperRR,R'RR&R%Rtdicttitemstupdate_values_to_settupdate_whereclause(R RRRRRtkeytvalue((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyR,Ζs .N(RRR-RR,(((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyRΓs N(RR(tRRtsqlRtsql.baseRtsql.dmlRtStandardInsertt sql.elementsRtsql.expressionRtutil.langhelpersRt__all__RRRR(((sU/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/dml.pyts{,