Re: [SQLObject] problem switching from MultipleJoin to SQLMultipleJoin
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Jason C. <jc...@xe...> - 2006-07-20 23:25:37
|
On Thu, 20 Jul 2006 14:55:21 -0700 (PDT) Donald Ball <ba...@fi...> wrote: > Hey guys, nice little ORM library you've got here. One question - I'm=20 > trying to switch one of my joins from MultipleJoin to SQLMultipleJoin > so i can count() and filter() the results. model.py: >=20 > class PollOption(SQLObject): > poll =3D ForeignKey("Poll") > value =3D UnicodeCol(dbName=3D"option_value") > responses =3D SQLMultipleJoin('Response') >=20 > class Response(SQLObject): > poll_option =3D ForeignKey("PollOption") > datetime =3D DateTimeCol(default=3Ddatetime.now) > ip_address =3D UnicodeCol(length=3D15, varchar=3D0) > token =3D ForeignKey("Token") >=20 > I just changed the responses property from MultipleJoin to=20 > SQLMultipleJoin... and now I get an error when I access the responses=20 > property: >=20 > >>> option.responses > Traceback (most recent call last): > File "<console>", line 1, in ? > File "<string>", line 1, in <lambda> > File=20 > "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlo= bject/joins.py",=20 > line 144, in performJoin > results =3D self.otherClass.select(getattr(self.otherClass.q,=20 > self.soClass.sqlmeta.style.dbColumnToPythonAttr(self.joinColumn)) =3D=3D= =20 > inst.id) > File=20 > "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlo= bject/sqlbuilder.py",=20 > line 362, in __getattr__ > self.soClass.sqlmeta.columns[attr].dbName, > KeyError: 'pollOptionID' >=20 > I dropped and recreated the database, same deal. What am I doing > wrong? >=20 > - donald If I'm not mistaken, you need a joinColumn argument in the "responses =3D SQLMultipleJoin('Response')". It'll either be joinColumn=3D"poll_option" or joinColumn=3D"poll_optionID". I can never quite remember. Given that, I'm surprised it worked as a MultipleJoin at all... Jason |