On 06/29/2011 05:40 PM, David Zmick wrote:
Okay. So I wrote a test case with similar behavior and it worked
correctly, but the difference between the test case objects and my
objects is that all of the test case objects are active records that get
saved, not just the top level object as in my code.
Nope, that wasn't the difference that mattered. You did find a bug, an
interesting one, but your test code was overly complex hiding what was
really going on. Here's a simpler test case that exposes the bug more
directly.
testObjectFoundMultipleTimesInAggregate
| obj key |
obj := SDPersonMock new.
obj children: Dictionary new.
key := Object new.
"store ref to key in two places"
obj children at: key put: 1.
obj children at: 1 put: key.
self deny: (obj children keys includes: nil).
self deny: (obj children values includes: nil).
obj save.
self flushAndReload.
self deny: (obj children keys includes: nil).
self deny: (obj children values includes: nil)
The bug has been fixed, pull down the latest code from SqueakSource and
your code with work fine. As you can see from the test case above, the
issue was related to an object being references in multiple places
inside an active record. During serialization, this exposed a silly bug
in the deep copy that I think I introduced recently with a round of
refactoring. Thanks for the bug report.
--
Ramon Leon
http://onsmalltalk.com