View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0007724 | VALENTINA STUDIO | PLUGIN - DB - SQLite Local | public | 2016-07-17 11:33 | 2019-09-27 21:37 |
Reporter | Ralf Bertling | Assigned To | Igor Nikitin | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | ALL | OS | ALL | OS Version | ALL |
Product Version | 6.4.x | ||||
Fixed in Version | 9.6.x | ||||
Summary | 0007724: Generated Schema changes remove links / foreign Keys on SQLite | ||||
Description | When using the GUI features to alter SQLite tables, existing foreign key constraints are silently dropped. Due to limitations of SQLIte, a fresh Table is always created for ALTER TABLE (Note: This would not be strictly necessary for Add Column, but that does not matter for my example) The create Script for the intermediate Table does not contain foreign keys that were created earlier. | ||||
Steps To Reproduce | Create a new SQLite DB Check the foreign key checkbox in DB-Properties. Issue the following commands (or use the attached SQLite file. BEGIN; CREATE TABLE "a"( "A_Id" Integer NOT NULL PRIMARY KEY, "A_Name" Text NOT NULL COLLATE NOCASE ); CREATE TABLE "b"( "B_Id" Integer NOT NULL PRIMARY KEY, "B_Name" Text NOT NULL COLLATE NOCASE ); CREATE TABLE "c"( "a_id" Integer NOT NULL, "b_id" Integer NOT NULL, "c_id" Integer NOT NULL PRIMARY KEY, CONSTRAINT "lnk_c_a" FOREIGN KEY ( "a_id" ) REFERENCES "a"( "A_Id" ) ); END; Now, try to add another link from table c to b on the column b_Id: The following SQL is generated by Valentina, effectively dropping the link lnk_c_a: BEGIN; -- CREATE LINK "lnk_c_b" --------------------------------------- DROP TABLE IF EXISTS "__vs_temp_table"; CREATE TABLE "__vs_temp_table"( "a_id" Integer NOT NULL, "b_id" Integer NOT NULL, "c_id" Integer NOT NULL PRIMARY KEY, CONSTRAINT "lnk_c_b" FOREIGN KEY ( "b_id" ) REFERENCES "b"( "B_Id" ) ); INSERT INTO "__vs_temp_table"("a_id","b_id","c_id") SELECT "a_id","b_id","c_id" FROM "c"; DROP TABLE IF EXISTS "c"; ALTER TABLE "__vs_temp_table" RENAME TO "c"; -- ------------------------------------------------------------- COMMIT; | ||||
Additional Information | The bug also seems to affect any other change on a table that links to another table. | ||||
Tags | No tags attached. | ||||
Working with DB: | SQLite Local DB | ||||
Version of your DB: | |||||
Date Modified | Username | Field | Change |
---|---|---|---|
2016-07-17 11:33 | Ralf Bertling | New Issue | |
2016-07-17 11:33 | Ralf Bertling | File Added: bug.sqlite | |
2019-09-27 21:37 | Igor Nikitin | Assigned To | => Igor Nikitin |
2019-09-27 21:37 | Igor Nikitin | Status | new => resolved |
2019-09-27 21:37 | Igor Nikitin | Resolution | open => fixed |
2019-09-27 21:37 | Igor Nikitin | Fixed in Version | => 9.6.x |