diff --git a/util/diff/diff.go b/util/diff/diff.go index cec9537b..dea5ba95 100644 --- a/util/diff/diff.go +++ b/util/diff/diff.go @@ -277,7 +277,7 @@ func (o *operations) vals(old, now interface{}, path string) { } case *sql.Thing: nv := now.(*sql.Thing) - if ov.TB != nv.TB && ov.ID != nv.ID { + if ov.TB != nv.TB || ov.ID != nv.ID { o.op("replace", "", path, old, now) } case bool: diff --git a/util/diff/diff_test.go b/util/diff/diff_test.go index 922dca34..2c1b3fb2 100644 --- a/util/diff/diff_test.go +++ b/util/diff/diff_test.go @@ -17,11 +17,14 @@ package diff import ( "testing" + "github.com/abcum/surreal/sql" + . "github.com/smartystreets/goconvey/convey" ) var old = map[string]interface{}{ - "age": 18, + "age": 18, + "item": sql.NewThing("test", 1), "name": map[string]interface{}{ "first": "T", "last": "M H", @@ -32,7 +35,8 @@ var old = map[string]interface{}{ } var now = map[string]interface{}{ - "age": 29, + "age": 29, + "item": sql.NewThing("test", 2), "name": map[string]interface{}{ "first": "Tobie", "last": "Morgan Hitchcock", @@ -97,6 +101,11 @@ var chg = []interface{}{ "path": "/different", "value": true, }, + map[string]interface{}{ + "op": "replace", + "path": "/item", + "value": sql.NewThing("test", 2), + }, map[string]interface{}{ "op": "change", "path": "/name/first",