summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/attributes.py8
-rw-r--r--lib/sqlalchemy/sql/expression.py4
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index a95ae0500..84c9dfbb6 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -251,8 +251,7 @@ class AttributeImpl(object):
def set_committed_value(self, state, value):
"""set an attribute value on the given instance and 'commit' it."""
- if state.committed_state is not None:
- state.commit_attr(self, value)
+ state.commit_attr(self, value)
# remove per-instance callable, if any
state.callables.pop(self.key, None)
state.dict[self.key] = value
@@ -395,7 +394,7 @@ class ScalarObjectAttributeImpl(ScalarAttributeImpl):
if self.trackparent:
if value is not None:
self.sethasparent(value._state, True)
- if previous is not None:
+ if previous is not value and previous is not None:
self.sethasparent(previous._state, False)
instance = state.obj()
@@ -544,7 +543,8 @@ class CollectionAttributeImpl(AttributeImpl):
if old is value:
return
- state.committed_state[self.key] = self.copy(old)
+ if self.key not in state.committed_state:
+ state.committed_state[self.key] = self.copy(old)
old_collection = self.get_collection(state, old)
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index b3b04b678..3dc7242d7 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -2815,7 +2815,7 @@ class _SelectBaseMixin(object):
form of this method instead to prevent this issue.
"""
- if clauses == [None]:
+ if len(clauses) == 1 and clauses[0] is None:
self._order_by_clause = ClauseList()
else:
if getattr(self, '_order_by_clause', None):
@@ -2833,7 +2833,7 @@ class _SelectBaseMixin(object):
form of this method instead to prevent this issue.
"""
- if clauses == [None]:
+ if len(clauses) == 1 and clauses[0] is None:
self._group_by_clause = ClauseList()
else:
if getattr(self, '_group_by_clause', None):