-
-
Notifications
You must be signed in to change notification settings - Fork 179
Issue627: Delete of soft deleted rows fails #628
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
Conversation
Added 'withSoftDelete:true' to delete so that soft deleted rows can be removed.
Added unit test for deleting a previously soft deleted row.
| /// - returns: Future that will be completed when the delete is done. | ||
| public func delete(force: Bool = false, on conn: DatabaseConnectable) -> Future<Void> { | ||
| return Self.query(on: conn).delete(self, force: force) | ||
| return Self.query(on: conn, withSoftDeleted: true).delete(self, force: force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think withSoftDeleted should only be true if force is true as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I'll add a case to the unit test and update the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code and extended the unit tests to cover the deletedAt property.
Added a test of the behavior of the updatedAt and deletedAt timestamps under soft delete.
Changed delete query based on value of 'force'.
Added second test to withSchema
Restructured to parallel BenchmarkTimestampable.swift.
Local only
This reverts commit d92d4cb.
Need to read the row after soft delete to fetch the deletedAt setting.
Oops. Must have withSoftDeleted set to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM, thank you!
I've created an issue here to double-check that Fluent 4 behaves correctly as well: vapor/fluent-kit#77
Simple fix and associated unit test.