Re: toOne relationship returns base class instead of subcl
Sebastien Bigaret <[email protected]> 23 Jul 2004 15:02:00 +0200
| Newsgroups | gmane.comp.python.modeling |
|---|---|
| Message-ID | <[email protected]> |
John Lenton <[email protected]> wrote: > in the model > > Person > / \ > | > PhysicalPerson <---->> Address > > querying an Address for its PhysicalPerson returns Person instances, > which was unexpected (for me, at least). Is this correct, or is it a > bug? If you mean that, having an address 'addr', addr.getPerson() has class 'Person', yes, this is intended, as long as addr.getPerson().isFault() is True. As soon as you'll need an addr's person property the fault will be fired and you'll get the correct class for addr.getPerson(). Now you may wonder why this is like this. We discussed this here: https://sourceforge.net/mailarchive/forum.php?thread_id=3457563&forum_id=10674 See esp. the third post dated 2003-11-15 20:40. While the example taken there involves a relationship pointing from a subclass to its root class, you'll see that you get exactly the same kind of problem if you add a class Photo such as: Photo <<---> Person Now you'll see that the discussion "ended" there with an open question, about if and how this could/should be changed. Time to rediscuss this I guess, huh? -- Sébastien. PS: BTW the interesting methods on this topic: DBChannel.fetchObject() calling DBContext.initializeObject(), which in particular populates the object's toOne properties with DBContext.faultForGlobalID(). and this particular behaviour is tested in: test_EC_Global_Inheritance.test_02_toOneFault() ------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_idG21&alloc_id040&op=click