summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-02-11 22:29:18 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-02-11 22:29:18 -0500
commit366f97b5617af0d15cfaf594ec5ef0408c70e873 (patch)
tree135c27cc1557045f508911e5b1cc7f629655926c /lib/sqlalchemy
parente5f1a3fb7dc1888ed187fdeae8171e4ff322dab6 (diff)
downloadsqlalchemy-366f97b5617af0d15cfaf594ec5ef0408c70e873.tar.gz
- Fixed bug in :meth:`.Session.merge` where an object with a composite
primary key that has values for some but not all of the PK fields would emit a SELECT statement leaking the internal NEVER_SET symbol into the query, rather than detecting that this object does not have a searchable primary key and no SELECT should be emitted. fixes #3647
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/session.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index 80bd902d0..48ff09b87 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -1768,9 +1768,10 @@ class Session(_SessionClassMethods):
self._update_impl(merged_state)
new_instance = True
- elif not _none_set.intersection(key[1]) or \
+ elif key_is_persistent and (
+ not _none_set.intersection(key[1]) or
(mapper.allow_partial_pks and
- not _none_set.issuperset(key[1])):
+ not _none_set.issuperset(key[1]))):
merged = self.query(mapper.class_).get(key[1])
else:
merged = None