Skip to content

deleted records can be queried in the same second #7204

@Diluka

Description

@Diluka

What you are doing?

querying records may contain deleted ones

// code here
// paranoid model User
await User.delete(1);
let user = await User.findById(1);

What do you expect to happen?

user is null

What is actually happening?

user maybe not null

Dialect: mysql
Database version: 5.7.16-1debian8
Sequelize version: 4.0.0-2

I've check #5880 and #5897.

  1. should use database time rather than servers'
    The server time may be inconsistent with the database time.
  2. should use $gt rather than $gte
    For all databases, the time accuracy of the database can only be guaranteed to seconds, so deleted records may be in the same seconds to be queried. To avoid this, the first query condition can not contain the current second, followed by all the time required to the database time.

some refers:
https://github.com/sequelize/sequelize/blob/master/lib/model.js#L80
https://github.com/sequelize/sequelize/blob/master/lib/model.js#L2445-L2452
https://github.com/sequelize/sequelize/blob/master/lib/utils.js#L426-L433

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featureDEPRECATED: replace with the "feature" issue typetype: refactorDEPRECATED: replace with the "meta" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions