aboutsummaryrefslogtreecommitdiff
path: root/transaction.go
diff options
context:
space:
mode:
Diffstat (limited to 'transaction.go')
-rw-r--r--transaction.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/transaction.go b/transaction.go
index 54aae8c..3951cd8 100644
--- a/transaction.go
+++ b/transaction.go
@@ -1,5 +1,9 @@
package bolt
+import (
+ "bytes"
+)
+
// Transaction represents a read-only transaction on the database.
// It can be used for retrieving values for keys as well as creating cursors for
// iterating over the data.
@@ -90,7 +94,12 @@ func (t *Transaction) Get(name string, key []byte) (value []byte, err error) {
if err != nil {
return nil, err
}
- return c.Get(key), nil
+ k, v := c.Seek(key)
+ // If our target node isn't the same key as what's passed in then return nil.
+ if !bytes.Equal(key, k) {
+ return nil, nil
+ }
+ return v, nil
}
// ForEach executes a function for each key/value pair in a bucket.