Soni Bergraj wrote:
Hello,
I'm tinkering with many-to-many relationships and more specific with
self references.

Let's stick with a bunch of Tradesmen (just as an example). One
Tradesman knows several suppliers and purchasers. And all of them are
tradesmen.

This gives us the following scheme:

   ------------- * purchaser
   | Tradesman |-----------
   -------------          |
        *|                |
supplier |                |
         ------------------

My solution so far is:

class Tradesman(SQLObject):
    name            = StringCol(alternateID = True)

    suppliers       = RelatedJoin('Tradesman',
            addRemoveName = 'Supplier',
            joinColumn = 'purchaser', otherColumn = 'supplier')

    purchasers      = RelatedJoin('Tradesman',
            addRemoveName = 'Purchaser',
            joinColumn = 'supplier', otherColumn = 'purchaser')

This way it seems to work smoothly. The only drawback is that table
creation fails with an error due to the attempt to create the table
'tradesman_tradesman' twice.

Is this the most convenient way to do self references, and if yes, is
there a way to prevent the second attempt to create 'tradesman_tradesman'?

Use intermediateTable to tell sqlobject to use a different table name.

Jürgen



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to