]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Skip on slice assignment to self
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 19 Nov 2019 14:30:31 +0000 (09:30 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 Nov 2019 17:50:03 +0000 (12:50 -0500)
commit24517c01041aaeb0dfcbc5cb7840e0f78b55e90e
treed2ab3935dd77aac13066b464e26b5d0a4726bd0b
parent38bb05c7cd7be4862b23235737217198e90ce0a3
Skip on slice assignment to self

Fixed issue where when assigning a collection to itself as a slice, the
mutation operation would fail as it would first erase the assigned
collection inadvertently.   As an assignment that does not change  the
contents should not generate events, the operation is now a no-op. Note
that the fix only applies to Python 3; in Python 2, the ``__setitem__``
hook isn't called in this case; ``__setslice__`` is used instead which
recreates the list item-by-item in all cases.

Fixes: #4990
Change-Id: I08727880f70f4fe188de53a4dcd36746b62c7233
(cherry picked from commit 560044748a8ff5488769f8ebfa8a353a8d0115fa)
doc/build/changelog/unreleased_13/4990.rst [new file with mode: 0644]
lib/sqlalchemy/orm/collections.py
test/orm/test_collection.py