You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this sample, I append data to list, saved, then do the 'for' loop, but when I call remove(), the append data was missed, and the 'remove' func didn't work.
F.
======================================================================
FAIL: test_mongoengine_with_iterate (test.DBTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "XXXX/dev/test.py", line 39, in test_mongoengine_with_iterate
self.assertTrue(b_1 in a.list_b)
AssertionError: False is not true
----------------------------------------------------------------------
Ran 2 tests in 0.017s
FAILED (failures=1)
The text was updated successfully, but these errors were encountered:
I strongly suspect that this issue was related to #1318; which is now resolved. But, unfortunately, the example code above contains a likely-unintentional bug. In testing the iteration, the following line is used:
for b in a.list_b: pass
This overwrites the original meaning of b. In fact, the for loop would leave the value of b to be b_1. So when:
a.list_b.remove(b)
is then executed, it is b_1 that is actually removed not the original b. In fact, the original reference to b is lost, so there is no way to remove it with the remove function. By changing the iteration to not overwrite the meaning of b :
for x in a.list_b: pass
Now the code functions as expected against the latest commit of master. I recommend closing this issue.
In this sample, I append data to list, saved, then do the 'for' loop, but when I call remove(), the append data was missed, and the 'remove' func didn't work.
The text was updated successfully, but these errors were encountered: