summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/dml.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/dml.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/dml.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/dml.py b/lib/sqlalchemy/dialects/postgresql/dml.py
index 50fd09528..78cad974f 100644
--- a/lib/sqlalchemy/dialects/postgresql/dml.py
+++ b/lib/sqlalchemy/dialects/postgresql/dml.py
@@ -7,6 +7,8 @@
from . import ext
from ... import util
+from ...sql import coercions
+from ...sql import roles
from ...sql import schema
from ...sql.base import _generative
from ...sql.dml import Insert as StandardInsert
@@ -77,12 +79,16 @@ class Insert(StandardInsert):
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.
+ A dictionary or other mapping object
+ where the keys are either names of columns in the target table,
+ or :class:`_schema.Column` objects or other ORM-mapped columns
+ matching that of the target table, and expressions or literals
+ as values, specifying the ``SET`` actions to take.
+
+ .. versionadded:: 1.4 The
+ :paramref:`_postgresql.Insert.on_conflict_do_update.set_`
+ parameter supports :class:`_schema.Column` objects from the target
+ :class:`_schema.Table` as keys.
.. warning:: This dictionary does **not** take into account
Python-specified default UPDATE values or generation functions,
@@ -229,6 +235,7 @@ class OnConflictDoUpdate(OnConflictClause):
if not isinstance(set_, dict) or not set_:
raise ValueError("set parameter must be a non-empty dictionary")
self.update_values_to_set = [
- (key, value) for key, value in set_.items()
+ (coercions.expect(roles.DMLColumnRole, key), value)
+ for key, value in set_.items()
]
self.update_whereclause = where