-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Labels
type: featureDEPRECATED: replace with the "feature" issue typeDEPRECATED: replace with the "feature" issue typetype: refactorDEPRECATED: replace with the "meta" issue typeDEPRECATED: replace with the "meta" issue type
Description
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
- should use database time rather than servers'
The server time may be inconsistent with the database time. - 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
Merracliuslp6moon, Wsiegenthaler and Merraclius
Metadata
Metadata
Assignees
Labels
type: featureDEPRECATED: replace with the "feature" issue typeDEPRECATED: replace with the "feature" issue typetype: refactorDEPRECATED: replace with the "meta" issue typeDEPRECATED: replace with the "meta" issue type