Hi!

On Sun, Nov 10, 2013 at 10:21:21PM +0100, Daniel Fetchinson 
<fetchin...@googlemail.com> wrote:
> Perhaps it is by design but I was kind of surprised to see that if I have
> 
> class x(SQLObject):
>     ys = RelatedJoin( 'y' )
> 
> class y(SQLObject):
>     ....
> 
> then I'm allowed to add several times the same 'y' object to 'x' via
> 
> myx = x.get( 1 )
> myy = y.get( 1 )
> x.addY( myy )
> x.addY( myy )
> x.addY( myy )
> 
> Is there a keyword argument to RelatedJoin or to addY that forbids this?

   There is no.

> Or I have to code this myself, i.e. check if an object is already
> added, and if yes, refuse to do it?

   It is application-dependent. Please remember that RelatedJoin is
many-to-many relation using an intermediate table. I cannot contrive a
task for which there could be a few intermediate rows with the same pair
of id's but who knows what tasks people can devise.
   The simplest thing you can do is to create unique indices for your
intermediate tables. The best thing you can do is to send a patch that
will create unique indices at the time of creation of RelatedJoin's.
With an option to turn the indices off.

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to