Skip to content

fix: report create/delete differences on empty structs#101

Open
aexvir wants to merge 1 commit intor3labs:masterfrom
aexvir:aexvir/fix-empty-structs-handling
Open

fix: report create/delete differences on empty structs#101
aexvir wants to merge 1 commit intor3labs:masterfrom
aexvir:aexvir/fix-empty-structs-handling

Conversation

@aexvir
Copy link

@aexvir aexvir commented Mar 8, 2023

closes #100

to address this issue I've added an eager return inside structValues that, if the struct has no fields, appends a single entry to the changelog for the struct itself; also added tests for this

wants, got := Set{"one": {}}, Set{} 
diff.Diff(wants, got)

diff.Changelog{
	diff.Change{
		Type: diff.DELETE,
		Path: []string{"one"},
		From: struct{}{},
		To: nil,
	},
}

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.

no differences reported for maps where values are empty structs

1 participant