From 0392aa904c305f366a39d853d550d8adea3b3684 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 14 Jun 2019 23:03:06 +0100 Subject: [PATCH] Use reflect to check for document changes --- db/document.go | 7 ++----- db/yield.go | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/db/document.go b/db/document.go index 656c915f..04756be1 100644 --- a/db/document.go +++ b/db/document.go @@ -18,11 +18,11 @@ import ( "fmt" "context" + "reflect" "github.com/abcum/surreal/kvs" "github.com/abcum/surreal/sql" "github.com/abcum/surreal/util/data" - "github.com/abcum/surreal/util/diff" "github.com/abcum/surreal/util/indx" "github.com/abcum/surreal/util/keys" ) @@ -207,10 +207,7 @@ func (d *document) forced(ctx context.Context) bool { } func (d *document) hasChanged(ctx context.Context) bool { - a, _ := d.initial.Data().(map[string]interface{}) - b, _ := d.current.Data().(map[string]interface{}) - c := diff.Diff(a, b) - return len(c) > 0 + return reflect.DeepEqual(d.initial, d.current) == false } func (d *document) shouldDrop(ctx context.Context) (bool, error) { diff --git a/db/yield.go b/db/yield.go index 716e7502..1bc3151a 100644 --- a/db/yield.go +++ b/db/yield.go @@ -106,6 +106,7 @@ func (d *document) yield(ctx context.Context, stm sql.Statement, output sql.Toke switch output { default: return nil, nil + case sql.DIFF: old, err := d.cold(ctx)