diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-08-13 11:00:58 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-08-13 11:00:58 -0400 |
commit | 96650157083f9c691a7a8a737724159cd6a1d668 (patch) | |
tree | 12ab36603a8a6dea75815b275e3aafabc6c60dfd /lib/sqlalchemy/orm/attributes.py | |
parent | abc5e848177ab6f688255ef2aa4fe4417ced99b0 (diff) | |
download | sqlalchemy-96650157083f9c691a7a8a737724159cd6a1d668.tar.gz |
- [feature] Adding/removing None from a mapped collection
now generates attribute events. Previously, a None
append would be ignored in some cases. Related
to [ticket:2229].
- [feature] The presence of None in a mapped collection
now raises an error during flush. Previously,
None values in collections would be silently ignored.
[ticket:2229]
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
-rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index d26ee61c3..08e536f71 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -1022,6 +1022,9 @@ def backref_listeners(attribute, key, uselist): return child def emit_backref_from_collection_append_event(state, child, initiator): + if child is None: + return + child_state, child_dict = instance_state(child), \ instance_dict(child) child_impl = child_state.manager[key].impl @@ -1207,7 +1210,6 @@ class History(History): def from_collection(cls, attribute, state, current): original = state.committed_state.get(attribute.key, _NO_HISTORY) current = getattr(current, '_sa_adapter') - if original is NO_VALUE: return cls(list(current), (), ()) elif original is _NO_HISTORY: |