Today I used DB Browser for SQLite, version 3.10.1 on a windows 7 machine,
and encountered what seems to be a bug, either in the SQLite browser or
SQLite as such.

 

If this is not the correct mailing list to post this in I apologize, just
let me know.

 

I had a table with foreign keys, and added "on delete cascade" via the
function "Modify table". The "create table" script then ended up like this. 

 

(Strange one that caused wrong cascaded deletes)

CREATE TABLE "tblSpeechInLanguage" ( `speechInLanguageID` INTEGER,
`speechID` INTEGER NOT NULL, `languageID` INTEGER NOT NULL, FOREIGN
KEY(`languageID`) REFERENCES `tblLanguage`(`languageID`), PRIMARY
KEY(`speechInLanguageID`), FOREIGN KEY(`speechID`) REFERENCES
`tblSpeech`(`speechID`) ON DELETE CASCADE )

 

I then tested the cascade action, and everything in the table was deleted,
not just those rows that should have been deleted. 

 

I then went back to a backup, did the whole thing again, and then everything
worked, but I noticed that the "create table" script was a little different.

 

(Corrrect one that worked)

CREATE TABLE "tblSpeechInLanguage" ( `speechInLanguageID` INTEGER,
`speechID` INTEGER NOT NULL, `languageID` INTEGER NOT NULL, FOREIGN
KEY(`speechID`) REFERENCES `tblSpeech`(`speechID`) on delete cascade,
FOREIGN KEY(`languageID`) REFERENCES `tblLanguage`(`languageID`), PRIMARY
KEY(`speechInLanguageID`) )

 

 

As you see (as far as I can see) everything is the same in both, except for
the order in which they appear (if you paste both scripts on two lines after
each other in something like notepad without word wrap, you can see it more
clearly). 

 

Magnus

 

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to