On Jun 29, 2011, at 3:22 PM, Torsten Landschoff wrote:

> Hi Michael, hi *,
> 
> here is another issue I ran into with SQLAlchemy. Basically, I am trying
> to map a filesystem like structure to SQL. Unfortunately, there is a
> difference in that the users can reorder the tree. I reduced my code to
> the attached example.
> 
> Mapping the structure worked quite good so far, until I noticed that I
> had duplicate entries in the same folder. So I added a unique constraint
> with the result that I can't overwrite the list of entries anymore:
> 
> folder.children = list(folder.children)
> 
> alone causes the problem. SQLAlchemy adds the 'new' entries first, which
> violates the unique constraint.

yeah ordering_list can't handle this use case.  It doesn't know how to 
"reverse" the order of two keys where a unique exists between them, that would 
imply it would know how to temporarily update the row to a third neutral value 
- only the flush procedure could allow an operation like this which is outside 
the scope of the ordering list itself.

> 
> Is there a way to do what I want without bigger changes to the code? For
> now, I will disable the unique constraint again and add some checks to
> the Python code.
> 
> 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 sqlalchemy@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.
> 
> <fsdemo.py>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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