On Mon, Feb 20, 2006 at 11:55:38PM -0300, Sam's Lists wrote:
> #!/usr/bin/python
> 
> from sqlobject import *
> 
> class Wstore(SQLObject):
>     companyId = StringCol(default=None, alternateID=True, length=60)
>     companyName = StringCol(default=None)
>     specialSearchR = SingleJoin('SpecialSearch')
> 
> class SpecialSearch(SQLObject):
>     companyId = ForeignKey('Wstore', alternateID=True)
>     secondStageMatch = StringCol(default=None)
> 
> connection = connectionForURI("mysql://root:[EMAIL PROTECTED]/testdb")
> sqlhub.processConnection = connection
> 
> Wstore._connection.debug = True
> SpecialSearch._connection.debug = True
> Wstore.createTable()
> SpecialSearch.createTable()
> 
> x=Wstore(companyId="TheCompany ", companyName="The Company")
> y=SpecialSearch(companyId=x.id, secondStageMatch="foo")
> 
> z=x.SpecialSearchR
> 
> ---------
> 
> So my first question is the line
>  y=SpecialSearch(companyId=x.id, secondStageMatch="foo")
> 
> That line seems to work, but I would have expected ForeignKeys to work more
> like
> y=SpecialSearch(companyId=x, secondStageMatch="foo")

   This is fixed in the repository. Will be in SQLObject 0.8.

> My second questions is the line
> z=x.SpecialSearchR
> ...this doesn't work at all.  I would have expected it to to return what I
> just stored in y.
> 
> Any idea why it doesn't work?

   First, case msimatch:

>     specialSearchR = SingleJoin('SpecialSearch')

   Second, you've forgotten to name a column for join.

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 xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to