Ensure record ID changes are detected in diff
This commit is contained in:
parent
38f0e3469e
commit
3d4081bd54
2 changed files with 12 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue