Skip to content

fix: sqlite find out deleteAt items problem - #8204

Closed
ghostpanda wants to merge 1 commit into
sequelize:masterfrom
ghostpanda:master
Closed

ghostpanda wants to merge 1 commit into
sequelize:masterfrom
ghostpanda:master

Conversation

@ghostpanda

Copy link
Copy Markdown

sqlite 1s 内可以查询已经删除的数据
deleted_at > CURRENT_TIMESTAMP
deleted_at > 2017-08-26 16:36:19

deleted_at > now
deleted_at > 2017-08-26 16:36:19.836 +00:00

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

sqlite 1s 内可以查询已经删除的数据
`deleted_at` > CURRENT_TIMESTAMP 
`deleted_at` > 2017-08-26 16:36:19

`deleted_at` > now
`deleted_at` > 2017-08-26 16:36:19.836 +00:00
@mention-bot

Copy link
Copy Markdown

@ghostpanda, thanks for your PR! By analyzing the history of the files in this pull request, we identified @sushantdhiman, @felixfbecker and @janmeier to be potential reviewers.

@janmeier janmeier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, needs a test to prevent regressions

@stale stale Bot added the stale label Sep 27, 2017
@stale

stale Bot commented Sep 27, 2017

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

@apricote

Copy link
Copy Markdown

There is already a testcase for this scenario at https://github.com/sequelize/sequelize/blob/master/test/integration/instance.test.js#L1685

The reason why it did not fail is the use of the Sinon fake timer. Compare the generated queries:

sequelize:master:

Executing (default): UPDATE `ParanoidUsers` SET `deletedAt`='1970-01-01 00:00:00.000 +00:00' WHERE `id` = 1 AND `deletedAt` IS NULL
Executing (default): SELECT `id`, `username`, `createdAt`, `updatedAt`, `deletedAt`, `ParanoidUserId` FROM `ParanoidUsers` AS `ParanoidUser` WHERE (`ParanoidUser`.`deletedAt` > CURRENT_TIMESTAMP OR `ParanoidUser`.`deletedAt` IS NULL);

ghostpanda:master:

Executing (default): UPDATE `ParanoidUsers` SET `deletedAt`='1970-01-01 00:00:00.000 +00:00' WHERE `id` = 1 AND `deletedAt` IS NULL
Executing (default): SELECT `id`, `username`, `createdAt`, `updatedAt`, `deletedAt`, `ParanoidUserId` FROM `ParanoidUsers` AS `ParanoidUser` WHERE (`ParanoidUser`.`deletedAt` > '1970-01-01 00:00:00.000 +00:00' OR `ParanoidUser`.`deletedAt` IS NULL);

As the Date returned by the fake timer is so far in the past, a small difference in the timing of the sqlite db and node does not matter here.

Is it possible to avoid the fake timer for this one test case?

@stale stale Bot removed the stale label Sep 30, 2017
@janmeier

janmeier commented Oct 2, 2017 •

Copy link
Copy Markdown
Member

@apricote Calling this.clock.restore() before the start of that test should work. Or if you like figure out which tests actually require fake timers and only use it in those tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants