diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-05-28 20:01:21 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-05-28 20:01:21 -0400 |
| commit | bc08ee9029258b23171bb67e191452e6c739c597 (patch) | |
| tree | dac856792e87f4f68bd37d4f070d61ce5db0c596 /lib/sqlalchemy/orm/dependency.py | |
| parent | d60b680e967ea70f0b6b572ff9febb12c48afd3e (diff) | |
| download | sqlalchemy-bc08ee9029258b23171bb67e191452e6c739c597.tar.gz | |
- Fixed a few edge cases which arise in the so-called "row switch"
scenario, where an INSERT/DELETE can be turned into an UPDATE.
In this situation, a many-to-one relationship set to None, or
in some cases a scalar attribute set to None, may not be detected
as a net change in value, and therefore the UPDATE would not reset
what was on the previous row. This is due to some as-yet
unresovled side effects of the way attribute history works in terms
of implicitly assuming None isn't really a "change" for a previously
un-set attribute. See also :ticket:`3061`. fixes #3060
Diffstat (limited to 'lib/sqlalchemy/orm/dependency.py')
| -rw-r--r-- | lib/sqlalchemy/orm/dependency.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 34a2af391..0d5a4f909 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -741,10 +741,15 @@ class ManyToOneDP(DependencyProcessor): self.key, attributes.PASSIVE_NO_INITIALIZE) if history: - for child in history.added: - self._synchronize(state, child, None, False, - uowcommit, "add") - + if history.added: + for child in history.added: + self._synchronize(state, child, None, False, + uowcommit, "add") + elif history.unchanged == [None]: + # this is to appease the case where our row + # here is in fact going to be a so-called "row switch", + # where an INSERT becomes an UPDATE. See #3060. + self._synchronize(state, None, None, True, uowcommit) if self.post_update: self._post_update(state, uowcommit, history.sum()) |
