DbMetal chokes on repeated foreign key references in SQLite - any ideas?
Posted
by DanM
on Stack Overflow
See other posts from Stack Overflow
or by DanM
Published on 2010-05-03T22:45:22Z
Indexed on
2010/05/03
22:58 UTC
Read the original article
Hit count: 288
I've been struggling to get DbMetal to process my SQLite database. I finally isolated the problem. It won't allow a table to have two foreign key references to the same column.
For example, a SQLite database with these two tables will fail:
CREATE TABLE Person
(
Id INTEGER PRIMARY KEY,
Name TEXT NOT NULL
);
CREATE TABLE Match
(
Id INTEGER PRIMARY KEY,
WinnerPersonId INTEGER NOT NULL REFERENCES Person(Id),
LoserPersonId INTEGER NOT NULL REFERENCES Person(Id)
);
I get this error:
DbMetal: Sequence contains more than one matching element
If I get rid of the second foreign key reference, no error occurs.
So, this works:
CREATE TABLE Match
(
Id INTEGER PRIMARY KEY,
WinnerPersonId INTEGER NOT NULL REFERENCES Person(Id),
LoserPersonId INTEGER NOT NULL
);
But I really need both "person" columns to reference the person table.
I submitted a bug report for this, but I could use a workaround in the meantime. Any ideas?
© Stack Overflow or respective owner