Skip to content
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

Delete of soft deleted rows fails #627

Closed
Jerry-Carter opened this issue Apr 29, 2019 · 5 comments
Closed

Delete of soft deleted rows fails #627

Jerry-Carter opened this issue Apr 29, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@Jerry-Carter
Copy link

If you have soft delete enabled, deleting a row will set the column associated with the 'deletedAtKey'. Following this with a forced delete will not result in the row being deleted. The following SQL is generated on PostgreSQL:

DELETE FROM "MyTable" WHERE ("MyTable"."deletedAt" IS NULL OR "MyTable"."deletedAt" > ($1)) AND "MyTable"."id" = ($2) [0x00022aab9bdf99ee (TIMESTAMP), 24 (BIGINT)]

where the timestamp ($1) is after the deletedAtKey column value. The fix may be as simple as changing '>' to '<'. There is currently not a unit test for this case.

@grundoon
Copy link
Member

Seems to me that there should be no deletedAt check at all if delete(force: true, on: ...)

@Jerry-Carter
Copy link
Author

I'm extending BenchmarkSoftDeletable.swift to cover this case. Will commit once I'm able to run it.

@MrMage
Copy link
Contributor

MrMage commented Apr 30, 2019

I am using the following, which should work:

User.query(on: connection, withSoftDeleted: true)
					.filter(\User.id == userID)
					.delete(force: true)

@Jerry-Carter
Copy link
Author

Pull request: #628

@tanner0101 tanner0101 added the bug Something isn't working label Oct 7, 2019
@tanner0101
Copy link
Member

Fixed in #628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants