diff icon indicating copy to clipboard operation
diff copied to clipboard

When Bool type = false, is missing from Type:create

Open CIpherWGO opened this issue 2 years ago • 1 comments

Hi

Test code using go 1.20:

type Test struct {
	ID   int64  `diff:"id,identifier"`
	Bool bool   `diff:"bool"`
	Test string `diff:"test"`
}

a := []Test{{ID: 1, Bool: true, Test: "Bool set to true"}}

b := []Test{{ID: 2, Bool: false, Test: "Bool set to false"}}

changelog, err := diff.Diff(a, b)

if err != nil {
	fmt.Println(err)
	return
}

fmt.Printf("%+v\n", changelog)

Gives:

  {Type:create Path:[2 id] From:<nil> To:2 parent:<nil>} {Type:create Path:[2 test] From:<nil> To:Bool set to false parent:<nil>}]

Field Bool is missing from create. Should also have:

  {Type:create Path:[2 bool] From:<nil> To:false parent:<nil>}

Any help is appreciated!

Thanks.

CIpherWGO avatar Feb 16 '23 20:02 CIpherWGO