On Thu, 20 Jul 2006 14:55:21 -0700 (PDT) Donald Ball <[EMAIL PROTECTED]> wrote:
> Hey guys, nice little ORM library you've got here. One question - I'm
> trying to switch one of my joins from MultipleJoin to SQLMultipleJoin
> so i can count() and filter() the results. model.py:
>
> class PollOption(SQLObject):
> poll = ForeignKey("Poll")
> value = UnicodeCol(dbName="option_value")
> responses = SQLMultipleJoin('Response')
>
> class Response(SQLObject):
> poll_option = ForeignKey("PollOption")
> datetime = DateTimeCol(default=datetime.now)
> ip_address = UnicodeCol(length=15, varchar=0)
> token = ForeignKey("Token")
>
> I just changed the responses property from MultipleJoin to
> SQLMultipleJoin... and now I get an error when I access the responses
> property:
>
> >>> option.responses
> Traceback (most recent call last):
> File "<console>", line 1, in ?
> File "<string>", line 1, in <lambda>
> File
> "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/joins.py",
>
> line 144, in performJoin
> results = self.otherClass.select(getattr(self.otherClass.q,
> self.soClass.sqlmeta.style.dbColumnToPythonAttr(self.joinColumn)) ==
> inst.id)
> File
> "/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1457-py2.4.egg/sqlobject/sqlbuilder.py",
>
> line 362, in __getattr__
> self.soClass.sqlmeta.columns[attr].dbName,
> KeyError: 'pollOptionID'
>
> I dropped and recreated the database, same deal. What am I doing
> wrong?
>
> - donald
If I'm not mistaken, you need a joinColumn argument in the "responses =
SQLMultipleJoin('Response')". It'll either be joinColumn="poll_option"
or joinColumn="poll_optionID". I can never quite remember.
Given that, I'm surprised it worked as a MultipleJoin at all...
Jason
signature.asc
Description: PGP signature
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ sqlobject-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
