implementing query
This commit is contained in:
parent
8356f6cd97
commit
4750ac69df
|
@ -1,6 +1,6 @@
|
|||
import ./datastore/datastore
|
||||
import ./datastore/fsds
|
||||
import ./datastore/sql
|
||||
# import ./datastore/sql
|
||||
import ./datastore/mountedds
|
||||
import ./datastore/tieredds
|
||||
|
||||
|
|
|
@ -81,10 +81,10 @@ method query*(
|
|||
|
||||
await lock.acquire()
|
||||
|
||||
let res = queries()
|
||||
iter.result = res
|
||||
|
||||
without res =? queries(), err:
|
||||
iter.finished = true
|
||||
return failure err
|
||||
|
||||
|
||||
iter.dispose = proc(): Future[?!void] {.async.} =
|
||||
discard sqlite3_reset(s)
|
||||
|
|
|
@ -140,10 +140,11 @@ proc query*(self: SQLiteBackend,
|
|||
self.db.env, queryStr).expect("should not fail")
|
||||
|
||||
s = RawStmtPtr(queryStmt)
|
||||
queryKey = $query.key & "*"
|
||||
|
||||
var
|
||||
v = sqlite3_bind_text(
|
||||
s, 1.cint, ($query.key & "*").cstring, -1.cint, SQLITE_TRANSIENT_GCSAFE)
|
||||
s, 1.cint, queryKey.cstring, queryKey.len().cint, SQLITE_TRANSIENT_GCSAFE)
|
||||
|
||||
if not (v == SQLITE_OK):
|
||||
return failure newException(DatastoreError, $sqlite3_errstr(v))
|
||||
|
|
|
@ -15,7 +15,7 @@ import ../dscommontests
|
|||
import ../querycommontests
|
||||
|
||||
proc testBasic[K, V, B](
|
||||
ds: SQLiteDatastore,
|
||||
ds: SQLiteBackend,
|
||||
key: K,
|
||||
bytes: V,
|
||||
otherBytes: V,
|
||||
|
@ -67,7 +67,7 @@ proc testBasic[K, V, B](
|
|||
|
||||
suite "Test Basic SQLiteDatastore":
|
||||
let
|
||||
ds = SQLiteDatastore.new(Memory).tryGet()
|
||||
ds = SQLiteBackend.new(Memory).tryGet()
|
||||
keyFull = Key.init("a:b/c/d:e").tryGet()
|
||||
key = keyFull.id()
|
||||
bytes = "some bytes".toBytes
|
||||
|
@ -85,7 +85,7 @@ suite "Test Basic SQLiteDatastore":
|
|||
|
||||
suite "Test DataBuffer SQLiteDatastore":
|
||||
let
|
||||
ds = SQLiteDatastore.new(Memory).tryGet()
|
||||
ds = SQLiteBackend.new(Memory).tryGet()
|
||||
keyFull = Key.init("a:b/c/d:e").tryGet()
|
||||
key = KeyId.new keyFull.id()
|
||||
bytes = DataBuffer.new "some bytes"
|
||||
|
|
Loading…
Reference in New Issue