Re: [SQLObject] A problem about "ForeignKey", help!!
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Oleg B. <ph...@ph...> - 2009-04-09 23:17:49
|
On Thu, Apr 09, 2009 at 11:44:52PM +0200, Hanjie wrote: > class postTable(SQLObject): > title = UnicodeCol(length=50) > content = UnicodeCol() > comments=MultipleJoin('commentTable') > > class commentTable(SQLObject): > post=ForeignKey('postTable') > authorName=UnicodeCol(length=255,notNull=False) > content=UnicodeCol() > > But, when I want to use q.comment, the error arise: > OperationalError: Unknown column 'post_table_id' in 'where clause' The problem lies here: class postTable(SQLObject): comments=MultipleJoin('commentTable') class commentTable(SQLObject): post=ForeignKey('postTable') There are simply too many different names: 'comments', 'commentTable', 'post' and 'postTable'. Multitude of these names confuses SQLObject so it doesn't know how to count comments of a post. One can help SQLObject by explicitly naming the column in the other table: class postTable(SQLObject): comments=MultipleJoin('commentTable', joinColumn='post_id') Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |