sqlitebrowser / sqlitebrowser/sqlitebrowser
'Duplicate Record' overwrites existing record
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
- I have a table with a CHECK constraint:
CREATE TABLE Table1
(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
Date DATETIME NOT NULL CHECK(Date IS strftime('%Y-%m-%d', Date)),
Value REAL NOT NULL,
Description TEXT DEFAULT NULL
);
- I have some records in the table:
INSERT INTO Table1 (Date, Value, Description) VALUES ('2017-12-06', 1.0, 'Value1');
INSERT INTO Table1 (Date, Value, Description) VALUES ('2017-12-06', 2.0, 'Value2');
INSERT INTO Table1 (Date, Value, Description) VALUES ('2017-12-06', 3.0, 'Value3');
INSERT INTO Table1 (Date, Value, Description) VALUES ('2017-12-06', 4.0, 'Value4');
INSERT INTO Table1 (Date, Value, Description) VALUES ('2017-12-06', 5.0, 'Value5');
- I select the first row of the table (i.e. the row with
_rowid_= 1), I right-click on that row and then I apply the "Duplicate record". These are the queries executed by the program:
INSERT INTO main.Table1(id,Date,Value) VALUES (6,'','');
UPDATE main.Table1 SET Value=? WHERE _rowid_='5';
UPDATE main.Table1 SET Description=? WHERE _rowid_='5';
The first query (the 'INSERT INTO ...') fails (correct, because the empty field-value for 'Date' does not pass the check) but the program continues. Therefore it updates the wrong record (overwriting an existing record)
Useful extra information
I'm opening this issue because:
- DB4S is crashing
- DB4S has a bug
- DB4S needs a feature
- DB4S has another problem
I'm using DB4S on:
- Windows: ( version: ___ )
- Linux: ( _distro: Ubuntu 16.04 )
- Mac OS: ( version: ___ )
- Other: ___
I'm using DB4S version:
- 3.10.99
- 3.10.0
- 3.9.1
- Other: ___
I have also:
- Tried out the latest nightly version: https://github.com/sqlitebrowser/sqlitebrowser#nightly-builds
- Searched for an existing similar issue: https://github.com/sqlitebrowser/sqlitebrowser/issues?utf8=%E2%9C%93&q=is%3Aissue%20
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
No source file or test is named. First reproduce the Duplicate record action with the shown CHECK constraint and inspect how the INSERT and subsequent UPDATE statements are executed. Done means a failed INSERT does not continue into updates that overwrite an existing record, with a regression test covering this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sqlite
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100