rko281 / ReStoreForPharo

Relational database persistence for Pharo objects
MIT License
32 stars 7 forks source link

Fix case of broken change detection for mutable fields (e.g. Bitmask) #23

Closed daniels220 closed 10 months ago

daniels220 commented 10 months ago

Specifically occurs after fault-in through polymorphic reference whose declared class does not have that field.

Set the #_class: of the proxy before assigning the proxiedObject, so that #initializeCopyObject will operate on the full list of fields for the class of the object, even if the reference was declared using a superclass.

Also raise an error if the retrieved class does not #includesBehavior: the declared/expected class (e.g. accidentally requesting deferredObjectOfClass: SubPerson withID: ).

rko281 commented 10 months ago

Thanks again.

The new test case testRetrievingIncompatibleClassRaisesError was failing in Pharo due to detailedID being nil. This was due to detailedID being the id_ of the result of the storeIn: which is actually a Boolean (possibly this should throw an error itself). The test was "passing" in Dolphin due to a key cannot be nil error; Pharo doesn't seem bothered about this however.

I'll submit a fix for this test and also the changes I applied to Dolphin (I can see now that you're using Pharo base methods, however the Dolphin versions work in Pharo too so I'll go with those).