sqlitebrowser / sqlitebrowser/sqlitebrowser
Foreign Key Constraint Changed Erroneously
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 24.6k
- Forks
- 2.4k
- Avg merge
- 3d 49m
- Merged PRs (30d)
- 3
Description
Details for the issue
What did you do?
I was attempting to add a record to a table which had a field with a foreign key constraint to another table.
What did you expect to see?
I expected that adding the record with a valid value for the field with the FK would be successful.
What did you see instead?
A foreign key constraint error would be thrown. I confirmed the value existed in the referenced table in the FK. Afterwards, I checked the FK constraint using the Database Structure tab to verify it was correct. However, the FK was changed to reference a different table. Which I thought was odd because I didn't change it. So I changed it back to the reference the correct table. However, after trying to add the new record I again was met with the same foreign key constraint error. I then went back to the Database Structure tab only to find that the FK reference table had been changed back to the wrong table again. I went back and forth several times with no luck. For some reason the FK reference table kept reverting back to the wrong table even though I corrected it and no error was shown. I tried closing the database and reopening. I tried closing the program and reopening but nothing worked. Eventually, I tried just adding the record using a valid value for the incorrectly referenced table just to see if I could add the row. I was able to. I was then able to change the referenced table for the FK to the correct one using the Database Structure tab finally. However, the referenced column changed erroneously the first time I tried to a column that I didn't select. I tried again to change it to the correct column and finally it took and everything looks good again for the FK. I was able to modify the row to the correct values finally.
I've been using this database without modification to the structure for a while now. I've added many rows to the tables I've described here without issue. This error occurred during a fairly long session of data entry (1-2 hours) where I was adding rows to the same tables. It was very strange but at the moment everything seems ok.
Useful extra information
DB4S v3.13.1 [built for x86_64-little_endian-llp64] on Windows 10 Version 2009 (winnt/10.0.22631) [x86_64]
using SQLite Version 3.46.1
and Qt 5.15.2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the foreign-key changes in DB4S v3.13.1 with SQLite 3.46.1 on Windows 10, using the Database Structure tab during a long data-entry session. Compare the selected reference table and column with the resulting constraint after inserting a row. Done means the incorrect table or column no longer replaces the user's selection, or the cause is documented with a reproducible case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sqlite
- Domain
- database, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100