Hi. It looks like bug. Could you open issue? 2016-09-28 15:36 GMT+02:00 Jan Cada <jan@cada.cz>:
Hi,
I started to play with slots and I am observing odd behaviour after the class structure gets changed.
I am having classes:
Object subclass: #*CTA* slots: { #x. #*b* => ToManyRelationSlot inverse: #*a* inClass: #*CTB* } classVariables: { } category: âClassTest'
and
Object subclass: #*CTB* slots: { #x. #*a* => ToOneRelationSlot inverse: #*b* inClass: #*CTA* } classVariables: { } category: âClassTest'
then I create instance of *CTA* and *CTB* pointing to *CTA*:
a1 := *CTA* new x: 1; yourself. b1 := *CTB* new x: 1; *a*: a1; yourself.
the a1 is updated as expected with *b* having RelationSet with my *CTB* instance.
The problem is when I decided to update the class *CTA* - changing position of slot #*b* => ToManyRelationSlot inverse: #*a* inClass: #CTB. In the case I drop all the instances of *CTA* and *CTB* and recreate new by code above, the inverse update always addresses slot on same position as before and not the one with right name.
For example when I change it like :
Object subclass: #*CTA* slots: { #x. #*children* => ToManyRelationSlot inverse: #parent inClass: # *CTA*. #*b* => ToManyRelationSlot inverse: #*a* inClass: #*CTB*. #parent => ToOneRelationSlot inverse: #children inClass: #*CTA* } classVariables: { } category: âClassTest'
the result of the code
a1 := *CTA* new x: 1; yourself. b1 := *CTB* new x: 1; *a*: a1; yourself.
is that slot *children* gets updated having RelationSet with my *CTB* instance instead of slot *b* which has empty RelationSet.
The question is: Am I doing something wrong ? Is there any way how to tell class to reinit slots as its order has changed ?
Thanks,
Jan