diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-09-10 14:14:50 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-09-10 14:14:50 -0400 |
commit | 14d2bb074cccdec32bd26a89353c30fd512b2aa2 (patch) | |
tree | b8bea89172c620f0f015edd5359681e304a19ac6 /lib/sqlalchemy/ext/orderinglist.py | |
parent | 706d4fcc4f69b74a502be41f5eea3fedd9413bc7 (diff) | |
download | sqlalchemy-14d2bb074cccdec32bd26a89353c30fd512b2aa2.tar.gz |
- Fixed bug in ordering list where the order of items would be
thrown off during a collection replace event, if the
reorder_on_append flag were set to True. The fix ensures that the
ordering list only impacts the list that is explicitly associated
with the object.
fixes #3191
Diffstat (limited to 'lib/sqlalchemy/ext/orderinglist.py')
-rw-r--r-- | lib/sqlalchemy/ext/orderinglist.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/orderinglist.py b/lib/sqlalchemy/ext/orderinglist.py index 67fda44c4..61155731c 100644 --- a/lib/sqlalchemy/ext/orderinglist.py +++ b/lib/sqlalchemy/ext/orderinglist.py @@ -119,7 +119,7 @@ start numbering at 1 or some other integer, provide ``count_from=1``. """ -from ..orm.collections import collection +from ..orm.collections import collection, collection_adapter from .. import util __all__ = ['ordering_list'] @@ -319,7 +319,10 @@ class OrderingList(list): def remove(self, entity): super(OrderingList, self).remove(entity) - self._reorder() + + adapter = collection_adapter(self) + if adapter and adapter._referenced_by_owner: + self._reorder() def pop(self, index=-1): entity = super(OrderingList, self).pop(index) |