Merge branch 'master' into symbolchecks
# Conflicts: # tests/test.nim
This commit is contained in:
commit
c8660925d3
|
@ -77,9 +77,11 @@ type
|
|||
LevelDbException* = object of CatchableError
|
||||
|
||||
IterNext* = proc(): (string, string) {.gcsafe, closure.}
|
||||
IterDispose* = proc() {.gcsafe, closure.}
|
||||
LevelDbQueryIter* = ref object
|
||||
finished*: bool
|
||||
next*: IterNext
|
||||
dispose*: IterDispose
|
||||
|
||||
const
|
||||
version* = block:
|
||||
|
@ -477,8 +479,13 @@ proc queryIter*(self: LevelDb, prefix: string = "", keysOnly: bool = false, skip
|
|||
else:
|
||||
return (keyStr, valueStr)
|
||||
|
||||
proc dispose() {.gcsafe, closure.} =
|
||||
if not iter.finished:
|
||||
iter.closeIter(iterPtr)
|
||||
|
||||
iter.finished = false
|
||||
iter.next = getNext
|
||||
iter.dispose = dispose
|
||||
return iter
|
||||
|
||||
proc removeDb*(name: string) =
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
author = "leveldbstatic authors"
|
||||
description = "Statically linked LevelDB wrapper for Nim"
|
||||
license = "MIT"
|
||||
|
|
|
@ -241,6 +241,22 @@ suite "leveldb queryIter":
|
|||
iter.next() == empty
|
||||
iter.finished
|
||||
|
||||
test "iterate until disposed":
|
||||
let iter = db.queryIter()
|
||||
check:
|
||||
not iter.finished
|
||||
iter.next() == (k1, v1)
|
||||
not iter.finished
|
||||
iter.next() == (k2, v2)
|
||||
not iter.finished
|
||||
|
||||
iter.dispose()
|
||||
|
||||
check:
|
||||
iter.finished
|
||||
iter.next() == empty
|
||||
iter.finished
|
||||
|
||||
test "skip":
|
||||
let iter = db.queryIter(skip = 1)
|
||||
check:
|
||||
|
|
Loading…
Reference in New Issue