On Mon, Jul 23, 2007 at 12:53:41PM -0700, Tim Black wrote:
> I'm trying to create more than one RelatedJoin between the same two
> classes. I need to construct many-to-many relationships between Persons
> and Projects
>
> class Person(SQLObject):
> name = StringCol()
> clientProjects = RelatedJoin("Project")
> contractorProjects = RelatedJoin("Project")
>
> class Project(SQLObject):
> name = StringCol()
> clients = RelatedJoin("Person")
> contractors = RelatedJoin("Person")
You have to understand that SQLObject creates a hidden intermediate
table that stores cross-pointers for an every pair of RelatedJoins. If you
want to create more than one RelatedJoin you have to give the name for the
tables yourself. Try this:
class Person(SQLObject):
name = StringCol()
clientProjects = RelatedJoin("Project",
intermediateTable="person_project_clients")
contractorProjects = RelatedJoin("Project",
intermediateTable="person_project_contractors")
class Project(SQLObject):
name = StringCol()
clients = RelatedJoin("Person", intermediateTable="person_project_clients")
contractors = RelatedJoin("Person",
intermediateTable="person_project_contractors")
And if you have crated your tables already you must create these
intermediate tables yourself:
Person.createJoinTables(ifNotExists=True)
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: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss