Closed simonw closed 11 months ago
Simplest possible recreation of the bug:
python -c '
import sqlite_utils
db = sqlite_utils.Database(memory=True)
db.execute("""
CREATE TABLE "logs" (
[id] INTEGER PRIMARY KEY,
[chat_id] INTEGER REFERENCES [log]([id]),
[reply_to_id] INTEGER
);
""")
db["logs"].add_foreign_key("reply_to_id", "logs", "id")
'
That chat_id
line is the line that causes the problem - because it is defining a reference to a table that no longer exists!
Although this is revealing a problem in the underlying code (that schema is invalid), it also represents a regression: sqlite-utils 3.34
ran this just fine, but it fails on sqlite-utils 3.35
due to the change made in:
I'm inclined to say this isn't a bug in sqlite-utils
though - it's a bug in the code that calls it. So I'm not going to fix it here.
Extremely detailed story of how I got to this point:
Steps to reproduce (only if that pragma is on though):
This succeeds in some environments, fails in others.