Great!!!
eventually, i find the problem!!!!
ForeignKey should use the same name with the related table.
How simple it is, but I waste a whole day on it!


Worry: post=ForeignKey('postTable')
correct: postTable=ForeignKey('
postTable')


On Fri, Apr 10, 2009 at 1:17 AM, Oleg Broytmann <phd@phd.pp.ru> wrote:
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/            phd@phd.pp.ru
          Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss