diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-21 11:31:29 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-21 11:31:29 -0400 |
| commit | 3a536ad1bad3efc272ade2914b3418844fe46b57 (patch) | |
| tree | 05775819657a95f142025bf43d55f761300c7d10 /lib/sqlalchemy/orm/dependency.py | |
| parent | a6906cd0a9588ae452f7171f4b08392f23232ef9 (diff) | |
| download | sqlalchemy-3a536ad1bad3efc272ade2914b3418844fe46b57.tar.gz | |
Fixed bug where many-to-many relationship with uselist=False
would fail to delete the association row and raise an error
if the scalar attribute were set to None. Also in 0.7.11.
[ticket:2710]
Diffstat (limited to 'lib/sqlalchemy/orm/dependency.py')
| -rw-r--r-- | lib/sqlalchemy/orm/dependency.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 8236e6944..7bb1d9736 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -863,7 +863,7 @@ class DetectKeySwitch(DependencyProcessor): related = state.get_impl(self.key).get(state, dict_, passive=self._passive_update_flag) if related is not attributes.PASSIVE_NO_RESULT and \ - related is not None: + related is not None: related_state = attributes.instance_state(dict_[self.key]) if related_state in switchers: uowcommit.register_object(state, @@ -1127,11 +1127,15 @@ class ManyToManyDP(DependencyProcessor): def _synchronize(self, state, child, associationrow, clearkeys, uowcommit, operation): - if associationrow is None: - return + # this checks for None if uselist=True self._verify_canload(child) + # but if uselist=False we get here. If child is None, + # no association row can be generated, so return. + if child is None: + return False + if child is not None and not uowcommit.session._contains_state(child): if not child.deleted: util.warn( |
