Re: toOne relationship returns base class instead of subcl

Sebastien Bigaret <[email protected]> 26 Aug 2004 21:46:30 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
John Lenton <[email protected]> wrote:
> On 29 Jul 2004 10:30:02 +0200, Sebastien Bigaret
> <[email protected]> wrote:
> >=20
> >   Again, could you be a little more explicit, or exhibit a short
> > example?  Sorry for getting back on this, but the only way I think this
> > can happen is the one I already posted (see below); if it's not the
> > case, this is a serious bug I definitely do not want to let escape.
>=20
> sorry for the delay in answering, and the confusion when doing so. I
> feel terribly embarrassed :(

  Please don't feel embarrassed, that was worth waiting for it.

> HOWever, here goes.
>=20
> With the attached model (which is ugly, and breaks some of your naming
> conventions, but I just hacked out the attributes and renamed things
> from the model being used by a team I'm helping to get up to speed),
> using vainilla MDL 0.9-pre17.1 and NF 0.7:
>=20
>=20
> >>> from Modeling.EditingContext import EditingContext
> >>> import Store
> >>> ec=3DEditingContext()
> >>> ec.fetch('Address')[0]
> <Address.Address object at 0x4071c74c>
> >>> a =3D _
> >>> p =3D ec.fetch('Person', isDeep=3D1)[0]
> <Employee.Employee object at 0x4072d88c>
> >>> p =3D _
> >>> a.getPerson()
> <Employee.Employee object at 0x4072d88c>
> >>> a.getPerson().getId()
> 1
> >>> a.isFault()
> False
> >>> p.getAddress()
> <Modeling.FaultHandler.AccessArrayFaultHandler instance at 0x40733a4c>
> >>> list(p.getAddress())
> [<Address.Address object at 0x4071c74c>]
> >>> ec.fetch('Address', 'Person.id =3D=3D 1')
> []
> >>> ec.fetch('Address', 'Person.id =3D=3D 1', isDeep=3D1)
> []

  Wooo, I didn't even realize how serious this was.  The 'isDeep' flag
  is unfortunately of no help here, because the problem is not with
  Address and its underlying hierarchy (controlled by 'isDeep' flag) but
  because of the generated SQL statement which  obviously doesn't take
  into account the sub-entities for entity Person:

    SELECT DISTINCT t0.ID, t0.FK_PERSON=20
    FROM ADDRESS t0, PERSON t1
    WHERE ( PERSON.ID =3D 1 ) AND ( ADDRESS.FK_PERSON =3D PERSON.ID )

I've just submitted bug item #1017127 at
https://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1017127&group=
_id=3D58935&atid=3D489335,
with your model and the corresponding code attached.

  I'll search a definitive fix soon --my current thinking being about
  the way that would allow even more complicated qualifiers to be
  correctly handled as well, such as with: person.addresses.id in [2,3]
  or w/ a qualifier traversing two or more relationships involving
  entities with sub-entities.

        Thanks a lot for the precise report,=20

-- S=E9bastien.



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285