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', rdb.Integer, primary_key=True, autoincrement=True),
    rdb.Column('left', rdb.String(length=32),
       rdb.ForeignKey("soup.uuid"), index=True),
    rdb.Column('right', rdb.String(length=32),
       rdb.ForeignKey("soup.uuid")),
    rdb.Column('order', rdb.Integer, nullable=False))

The soup table:
--------

table = rdb.Table(
     'soup',
     metadata,
     rdb.Column('id', rdb.Integer, primary_key=True, autoincrement=True),
     rdb.Column('uuid', rdb.String(length=32), unique=True, index=True),
     rdb.Column('spec', rdb.String, index=True),
     )


The relation property that should behave like an ordered list:
---------

orm.relation(
      bootstrap.Relation,
      primaryjoin=soup_table.c.uuid==relation_table.c.left,
      collection_class=RelationList,
      enable_typechecks=False)

I reproduce the problem like so:

1) Append some new item to the list, save and commit.
2) Repeat (1); an ``IntegrityError`` is raised:

IntegrityError: (IntegrityError) insert or update on table "relation" 
violates foreign key constraint "relation_right_fkey"
     DETAIL:  Key (right)=(tcbb53226374211dd8a730017f2d1db9) is not 
present in table "soup".
      'INSERT INTO relation (id, "left", "right", "order") VALUES 
(%(id)s, %(left)s, %(right)s, %(order)s)' {'left': 
'tcbb31e28374211dd8a730017f2d1db9', 'right': 
'tcbb53226374211dd8a730017f2d1db9', 'order': 1, 'id': 2L}

Any clues are greatly appreciated.

\malthe


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to