Skip to content

Commit

Permalink
fix: Mark docs as deleted when querying in delete mut (#2298)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves #1846

## Description

Marks docs as deleted when querying _deleted in delete mutation.
  • Loading branch information
AndrewSisley authored Feb 8, 2024
1 parent 89efbc4 commit ea511f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 4 additions & 0 deletions planner/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (n *deleteNode) Next() (bool, error) {
if err != nil {
return false, err
}

n.currentValue.Status = client.Deleted
n.documentMapping.TrySetFirstOfName(&n.currentValue, request.DeletedFieldName, true)

return true, nil
}

Expand Down
5 changes: 1 addition & 4 deletions tests/integration/mutation/delete/with_deleted_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

// This test documents a bug, see:
// https://github.com/sourcenetwork/defradb/issues/1846
func TestMutationDeletion_WithDeletedField(t *testing.T) {
test := testUtils.TestCase{
Actions: []any{
Expand All @@ -43,8 +41,7 @@ func TestMutationDeletion_WithDeletedField(t *testing.T) {
}`,
Results: []map[string]any{
{
// This should be true, as it has been deleted.
"_deleted": false,
"_deleted": true,
"_docID": "bae-decf6467-4c7c-50d7-b09d-0a7097ef6bad",
},
},
Expand Down

0 comments on commit ea511f0

Please sign in to comment.