ForeignKey reference can't be used multiple times at table creation

Issue #1238 resolved
Former user created an issue

The following code shows the problem:

from sqlalchemy import MetaData, Table, Column, Integer, ForeignKey

m = MetaData("sqlite:///foo")

s = Table("spam", m,
          Column("id", Integer, primary_key=True))

f = ForeignKey("spam.id")

t = Table("eggs", m,
          Column("s1", Integer, f),
          Column("s2", Integer, f))

s.create()
t.create()

The foreign key will be missing for eggs.s1:

andre@pb:~/tmp$ sqlite3 foo
SQLite version 3.4.0
Enter ".help" for instructions
sqlite> .schema
CREATE TABLE eggs (
        s1 INTEGER,
        s2 INTEGER,
         FOREIGN KEY(s2) REFERENCES spam (id)
);
CREATE TABLE spam (
        id INTEGER NOT NULL,
        PRIMARY KEY (id)
);

I tested sqlalchemy 0.4.8 and 0.5.0rc4 using sqlight and postgres.

Comments (1)

  1. Log in to comment