-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Duplicate Record' overwrites existing record #1255
Comments
Ouch, that sounds like a potentially nasty bug. 😦 |
Reproducible on Mac OS latest version 3.10.1 too |
|
Thanks for double checking @epraveenns. 😄 @MKleusberg @mgrojo This one sounds important! |
Ideal query would be
If the column is not auto increment, then all we can do is to blindly duplicate the row. It will then throw an error as the primary key is already taken. I don't understand
I Need to walkthrough its code. Correct me if I am wrong. |
That avoids overwriting existing record as reported in issue #1255. This doesn't improve the underlying situation, that is inserting empty rows before duplicating the content. But it is safer to not ignore the error in the initial row insertion.
The error in the first step, inserting an empty row, was ignored. I've improved that, by checking the error and aborting with the message to the user. Now the overwrite does not occur, that is the most important issue. This doesn't improve the underlying situation, that is inserting empty rows before duplicating the content. But it is safer to not ignore the error in the initial row insertion. |
Hmmm, I wonder if the reason it's inserting an empty row, is something to do with the way we do "Create a new Record?". (bad cut-n-paste maybe for initial duplication code?) From memory, when the user presses the "Create new record" button, we insert an empty row first for some reason. I think that's to make sure any default values for fields get created, and we can populate them into the row data fields onscreen for the user. That's purely from really old memory of how I remember it being explained one time. So... don't take that as definitely 100% correct. 😄 |
Well, for this database we have also problems creating new records 😞 At least this time the error is displayed:
|
Details for the issue
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);
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');_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
SETValue
=? WHERE_rowid_
='5';UPDATE
main
.Table1
SETDescription
=? 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:
I'm using DB4S on:
I'm using DB4S version:
I have also:
The text was updated successfully, but these errors were encountered: