On Nov 18, 2010, at 11:01 AM, Torsten Landschoff wrote:

> Hi Michael,
> 
> Thanks for your lightning fast reply!
> 
> On Thu, 2010-11-18 at 10:17 -0500, Michael Bayer wrote:
> 
>> this is correct.  The functionality provided by "secondary" is that SQLA 
>> will maintain a table with foreign keys to the related primary keys on 
>> either side.  It does not do anything at all with additional columns on the 
>> "secondary" table.   If your "secondary" table has additional columns you 
>> need to deal with, you no longer use "secondary" and instead use the 
>> association object pattern : 
>> http://www.sqlalchemy.org/docs/orm/relationships.html#association-object .   
>>  To make this pattern act more like "secondary" in the usual case, you use 
>> associationproxy:  
>> http://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html
>> 
>> You could most likely use the existing orderinglist extension in conjunction 
>> with associationproxy to maintain the ordering you want, in Python.
> 
> Okay, I updated my example code and it actually works now. However, it
> feels like a lot of additional complexity just for adding order.

Hm, I just looked at the script and compared it to your previous two pages of 
Mapper/Session extensions, seems a lot simpler to me !

The relationship + secondary approach does support "ordering" by an extra 
column in the association table, it just doesn't support direct mutation of 
that value.  

The rationale for the association object pattern is that it is a consistent way 
of establishing full control over the "secondary" table, using the exact same 
paradigms as that which grant control over the rows of any other table.   If we 
did it via flags and switches to relationship(), the API and internal 
complexity would increase significantly as would the potential for bugs, not to 
mention ambiguity in preferred methodology.




> 
> Greetings, Torsten
> 
> -- 
> DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH
> Torsten Landschoff
> 
> Office Dresden
> Tel: +49-(0)351-4519587
> Fax: +49-(0)351-4519561
> 
> mailto:torsten.landsch...@dynamore.de
> http://www.dynamore.de
> 
> Registration court: Mannheim, HRB: 109659, based in Karlsruhe,
> Managing director:  Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalch...@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 
> <association_object.py>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to