I posted this on the TurboGears list last week, and don't desire to cross-post. But as it didn't receive a substantive answer, perhaps it is better to send it directly to the SQLObject list. Thanks for your consideration. - Tim

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, because:

- one project can have multiple clients (when it's an open-source project)
- one project can have multiple contractors working on it
- one person can work as a contractor on multiple projects
- one person can be the client that pays for multiple projects
- one person can be a client on one project and a contractor on another project

Is it possible to do this in SQLObject?  How?

I've tried to represent this simply as:

class Person(SQLObject):
   name = StringCol()
   clientProjects = RelatedJoin("Project")
   contractorProjects = RelatedJoin("Project")

class Project(SQLObject):
   name = StringCol()
   clients = RelatedJoin("Person")
   contractors = RelatedJoin("Person")

But, when I add a client to a project in Catwalk, that client appears as a contractor as well on the same project! Makes sense; for example, I shouldn't expect SQLObject to distinguish between two identical references to RelatedJoin("Project"). But how can I distinguish the two references properly?

I've tried various combinations of using joinColumn, otherColumn, and intermediateTable, but no success yet. The documentation on joinColumn and otherColumn is not readily understandable; perhaps a UML diagram of the references between the classes and database tables could clarify the documentation. The best luck I've had yet was to specify two intermediateTables - one for the project_client relation and one for the project_contractor relation. But, that resulted in all persons being added as clients, even when I tried to add them as contractors.

Tim Black
-------------------------------------------------------------------------
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
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to