Hi Oleg,

I got sidetracked on something else and am only now able to get back to this. 
Thank you for your reply.

On Friday 31 July 2009 12:29:55 Oleg Broytmann wrote:
> On Fri, Jul 31, 2009 at 09:36:19AM +0200, Tom Coetser wrote:
> > I am trying to get my head around using a ManyToMany relation between
[snip]
>    The worst problem with ManyToMany is not documentation. The code was
> added by the original author before he left the project, and I don't know
> if the code by any means complete. I never used it. Consider it an
> unfinished experimental code. Use RelatedJoin or SQLRelatedJoin instead.

Noted, thank you.

[snip]

I am now using this option but have a question w.r.t. destroySelf(). Given the 
following:

-------- cut ---------------------
class Member(SQLObject):
    name = StringCol(alternateID=True)
    roles = SQLRelatedJoin('Role', intermediateTable='member_role',
                               createRelatedTable=False)

class Role(SQLObject):
    name = StringCol(alternateID=True)
    members = SQLRelatedJoin('Member', intermediateTable='member_role',
                               createRelatedTable=False)

class MemberRole(SQLObject):
    member = ForeignKey('Member', notNull=True, cascade=False)
    role = ForeignKey('Role', notNull=True, cascade=False)
-------- cut ---------------------

I can create members and roles and add roles to members using the addRole() 
auto method and vice versa for members to roles.

When I call destroySelf() on a member though, I would like to **not** have 
that member deleted if it still has any roles assigned to it. I tried setting 
the cascade=False option in the intermediate table, but this does not help 
because it looks like the base destroySelf() method automatically deletes any 
RelatedJoins.

So the question is: is it possible to manage the intermediate table myself, 
still use the RelatedJoin functionality to get the benefit of the auto
add....()  methods, but somehow indicate to destroySelf() whether deletes on 
records in the intermediate table should be cascaded or not?
In other words, can I have my cake AND eat it? :-)


Thanks,
 Tom

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to