From 8cce4ad1856e70de62258c1fc349fa1e1acf35f3 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Thu, 8 Feb 2018 10:59:54 +0000 Subject: [PATCH] No need for PutC as we always already have the record value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t need to check whether the record already exists, as we always have any record contents when we are procesing a document. Therefore we already know if a document exists or not in the kv store. --- db/create.go | 2 +- db/document.go | 25 ------------------------- db/insert.go | 2 +- db/relate.go | 2 +- 4 files changed, 3 insertions(+), 28 deletions(-) diff --git a/db/create.go b/db/create.go index ca296d42..6d7b5ff8 100644 --- a/db/create.go +++ b/db/create.go @@ -128,7 +128,7 @@ func (d *document) runCreate(ctx context.Context, stm *sql.CreateStatement) (int return nil, err } - if err = d.startThing(); err != nil { + if err = d.storeThing(); err != nil { return nil, err } diff --git a/db/document.go b/db/document.go index df65791a..858ecb0d 100644 --- a/db/document.go +++ b/db/document.go @@ -306,31 +306,6 @@ func (d *document) shouldDrop() (bool, error) { } -func (d *document) startThing() (err error) { - - // Check that the table should - // drop data being written. - - if ok, err := d.shouldDrop(); ok { - return err - } - - // Check that the rcord has been - // changed, and if not, return. - - if ok := d.changed(); !ok { - return - } - - // Write the value to the data - // layer and return any errors. - - _, err = d.i.e.dbo.PutC(d.now, d.key.Encode(), d.current.Encode(), nil) - - return - -} - func (d *document) storeThing() (err error) { // Check that the table should diff --git a/db/insert.go b/db/insert.go index 93216538..5aec28d9 100644 --- a/db/insert.go +++ b/db/insert.go @@ -106,7 +106,7 @@ func (d *document) runInsert(ctx context.Context, stm *sql.InsertStatement) (int return nil, err } - if err = d.startThing(); err != nil { + if err = d.storeThing(); err != nil { return nil, err } diff --git a/db/relate.go b/db/relate.go index 81fcd7ab..47fa4b63 100644 --- a/db/relate.go +++ b/db/relate.go @@ -120,7 +120,7 @@ func (d *document) runRelate(ctx context.Context, stm *sql.RelateStatement) (int return nil, err } - if err = d.startThing(); err != nil { + if err = d.storeThing(); err != nil { return nil, err }