DbMetal chokes on repeated foreign key references in SQLite - any ideas?

为君一笑 提交于 2019-12-11 07:52:17

问题


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?


回答1:


I just had the same problem and created a patch. I've also posted it at your bug report. For others, you can find the patch here: http://pastebin.com/VhNptMqp.



来源:https://stackoverflow.com/questions/2761701/dbmetal-chokes-on-repeated-foreign-key-references-in-sqlite-any-ideas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!