From 8f3aea74eae6244698b94a1b2b30682d76905508 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Wed, 8 Mar 2023 16:12:09 +0700 Subject: [PATCH] save (#100) --- mdbx/cursor.go | 2 +- mdbx/cursor_test.go | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/mdbx/cursor.go b/mdbx/cursor.go index 02dcb7e..d3f4181 100644 --- a/mdbx/cursor.go +++ b/mdbx/cursor.go @@ -168,7 +168,7 @@ func (c *Cursor) Get(setkey, setval []byte, op uint) (key, val []byte, err error if op == Set { key = setkey } else { - if op != LastDup { + if op != LastDup && op != FirstDup { key = castToBytes(c.txn.key) } } diff --git a/mdbx/cursor_test.go b/mdbx/cursor_test.go index 9a95bde..576ff42 100644 --- a/mdbx/cursor_test.go +++ b/mdbx/cursor_test.go @@ -316,16 +316,29 @@ func TestLastDup(t *testing.T) { return err } i++ + _, v, err := c.Get(nil, nil, LastDup) if err != nil { return err } if i == 1 && string(v) != "value1.3" { - t.Fail() + panic(1) } if i == 2 && string(v) != "value3.3" { - t.Fail() + panic(1) + } + + _, v, err = c.Get(nil, nil, FirstDup) + if err != nil { + return err + } + if i == 1 && string(v) != "value1.1" { + panic(1) } + if i == 2 && string(v) != "value3.1" { + panic(1) + } + } return nil