summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/dml.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2017-01-13 12:43:24 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2017-01-13 14:33:42 -0500
commitafd78a37dafe8e84e23bccfb570bd758797e2142 (patch)
tree3f194e4c19b7b0c81f7f62a67fdb1a7ca763b013 /lib/sqlalchemy/dialects/postgresql/dml.py
parent0460bc79d9986132646049d8167bd5dbe3388a65 (diff)
downloadsqlalchemy-afd78a37dafe8e84e23bccfb570bd758797e2142.tar.gz
Use full column->type processing for ON CONFLICT SET clause
Fixed bug in new "ON CONFLICT DO UPDATE" feature where the "set" values for the UPDATE clause would not be subject to type-level processing, as normally takes effect to handle both user-defined type level conversions as well as dialect-required conversions, such as those required for JSON datatypes. Additionally, clarified that the keys in the set_ dictionary should match the "key" of the column, if distinct from the column name. A warning is emitted for remaining column names that don't match column keys; for compatibility reasons, these are emitted as they were previously. Fixes: #3888 Change-Id: I67a04c67aa5f65e6d29f27bf3ef2f8257088d073
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/dml.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/dml.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/dml.py b/lib/sqlalchemy/dialects/postgresql/dml.py
index df53fa8a2..bfdfbfa36 100644
--- a/lib/sqlalchemy/dialects/postgresql/dml.py
+++ b/lib/sqlalchemy/dialects/postgresql/dml.py
@@ -70,6 +70,8 @@ class Insert(StandardInsert):
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,
@@ -205,7 +207,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, _literal_as_binds(value))
+ (key, value)
for key, value in set_.items()
]
self.update_whereclause = where