On Mon, Mar 10, 2008 at 02:16:46PM +0100, cedric briner wrote:
> sqlobject=9.4
> 
> class Person(SQLObject):
>     sn = UnicodeCol()
>     guarantor = ForeignKey('Person')
>     #
>     # guaranteds ; the opposed of guarantor like guest/host
>     guaranteds = MultipleJoin('person')
> 
> boss = Person(sn='The boss', guarantor=None)
> l1   = Person(sn="labor 1", guarantor=boss)
> l2   = Person(sn="labor 2", guarantor=boss)
> 
> This work fine
> l1.guarantor
> #<Person 1L sn=u'The boss' guarantorID=None>
> 
> # but this one not at all
> boss.guaranteds

   There are two problems in

>     guaranteds = MultipleJoin('person')

   The problem number one: MultipleJoin('person') - 'person' must be the
Python name of the class. In this case it is 'Person'.

   The problem number two is that MultipleJoin cannot find the
corresponding ForeignKey because the names of the columns do not match.
Just help the join by providing the db name of the key:

    guaranteds = MultipleJoin('Person', joinColumn="guarantor_id")

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to