Don’t use diffing in SQL export

This commit is contained in:
Tobie Morgan Hitchcock 2019-10-03 19:15:36 +01:00
parent 6a236b27b2
commit 0ea0942378

View file

@ -18,14 +18,11 @@ import (
"fmt" "fmt"
"math" "math"
"encoding/json"
"github.com/abcum/fibre" "github.com/abcum/fibre"
"github.com/abcum/surreal/cnf" "github.com/abcum/surreal/cnf"
"github.com/abcum/surreal/kvs" "github.com/abcum/surreal/kvs"
"github.com/abcum/surreal/sql" "github.com/abcum/surreal/sql"
"github.com/abcum/surreal/util/data" "github.com/abcum/surreal/util/data"
"github.com/abcum/surreal/util/diff"
"github.com/abcum/surreal/util/keys" "github.com/abcum/surreal/util/keys"
) )
@ -260,9 +257,7 @@ TB:
// then loop over all the items and // then loop over all the items and
// process the records. // process the records.
o := data.New()
n := data.New() n := data.New()
p := new(keys.Thing)
for _, kv := range vls { for _, kv := range vls {
@ -275,8 +270,6 @@ TB:
n = data.New().Decode(kv.Val()) n = data.New().Decode(kv.Val())
if p.TB != k.TB || p.ID != k.ID {
j, _ := n.MarshalJSON() j, _ := n.MarshalJSON()
if TB.Vers { if TB.Vers {
@ -285,21 +278,6 @@ TB:
fmt.Fprintf(w, "UPDATE ⟨%s⟩:⟨%s⟩ CONTENT %s;\n", k.TB, k.ID, j) fmt.Fprintf(w, "UPDATE ⟨%s⟩:⟨%s⟩ CONTENT %s;\n", k.TB, k.ID, j)
} }
} else {
a, _ := o.Data().(map[string]interface{})
b, _ := n.Data().(map[string]interface{})
c := diff.Diff(a, b)
j, _ := json.Marshal(c)
if TB.Vers {
fmt.Fprintf(w, "UPDATE ⟨%s⟩:⟨%s⟩ DIFF %s VERSION %d;\n", k.TB, k.ID, j, v)
} else {
fmt.Fprintf(w, "UPDATE ⟨%s⟩:⟨%s⟩ DIFF %s;\n", k.TB, k.ID, j)
}
}
} else { } else {
if TB.Vers { if TB.Vers {
@ -310,8 +288,6 @@ TB:
} }
p, o = k, n
} }
// When we loop around, we will use // When we loop around, we will use