Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Jerry-Carter
Copy link

Simple fix and associated unit test.

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)
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Author

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.

Jerry-Carter and others added 9 commits May 3, 2019 10:18
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.
Need to read the row after soft delete to fetch the deletedAt setting.
Oops.  Must have withSoftDeleted set to true.
@tanner0101 tanner0101 added the bug Something isn't working label Oct 7, 2019
Copy link
Member

@tanner0101 tanner0101 left a 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

@tanner0101 tanner0101 merged commit 783819d into vapor:3 Oct 7, 2019
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

Successfully merging this pull request may close these issues.

5 participants