[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-12 Thread Malthe Borch
Michael Bayer wrote: The most crucial, although not the issue in this specific example, is that the relations table is used both as the secondary table in a relation(), and is also mapped directly to the Relation class. SQLA does not track this fact and even in a working mapping will

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-12 Thread Michael Bayer
On Jun 12, 2008, at 4:48 AM, Malthe Borch wrote: Certainly stable is good; strictly looking at FKs only might ultimately make for a simpler implementation though. It starts out as simpler, but that simplicity breaks down almost immediately as the dependency rules, which include rules

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-11 Thread Malthe Borch
I can add to this that the issue occurs only on consequent appends. Here's the excerpt that leads to the IntegrityError, demonstrating this. collection = Collection() session.save(collection) session.flush() vinyl = Vinyl() colletion.records.append(vinyl)

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-11 Thread Michael Bayer
you'd have to work this into a full self-contained script which I can run locally since it seems theres some specific usage pattern creating the issue. (i.e. its very difficult for me to piece together snippets and guess where the issue might be occuring). On Jun 11, 2008, at 5:43 AM,

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-11 Thread Malthe Borch
Michael Bayer wrote: you'd have to work this into a full self-contained script which I can run locally since it seems theres some specific usage pattern creating the issue. (i.e. its very difficult for me to piece together snippets and guess where the issue might be occuring). This is

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-11 Thread Michael Bayer
thanks for this example. There's several issues with this mapping. The most crucial, although not the issue in this specific example, is that the relations table is used both as the secondary table in a relation(), and is also mapped directly to the Relation class. SQLA does not track

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-10 Thread Michael Bayer
On Jun 10, 10:34 am, Malthe Borch [EMAIL PROTECTED] wrote: I have an issue with SQLAlchemy planning to execute insertion tasks in the wrong order. Basically, I have a utility table Relations which is used to maintain ordered list relations: table = rdb.Table( 'relation',

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-10 Thread Malthe Borch
Michael Bayer wrote: A self-referential relationship, when configured as many-to-one, requires the remote_side argument to indicate this, as described in http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_selfreferential . Otherwise it defaults to one-to-many. That

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-10 Thread Michael Bayer
would need to see mappings. On Jun 10, 2008, at 11:06 AM, Malthe Borch wrote: Michael Bayer wrote: A self-referential relationship, when configured as many-to-one, requires the remote_side argument to indicate this, as described in

[sqlalchemy] Re: Insertion order not respecting FK relation

2008-06-10 Thread Malthe Borch
Michael Bayer wrote: would need to see mappings. First, let me mention that this issue only occurs on Postgres; I can't replicate it on SQLite. This is the many-to-many relation table (posted previously): table = rdb.Table( 'relation', metadata, rdb.Column('id',