Skip to content

'Duplicate Record' overwrites existing record #1255

@cyrano-68

Description

@cyrano-68

Details for the issue

  1. 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
);

  1. 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');

  1. 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    SQLbugConfirmed bugs or reports that are very likely to be bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions