implementing query

This commit is contained in:
Jaremy Creechley 2023-09-21 18:08:00 -07:00
parent 8356f6cd97
commit 4750ac69df
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
4 changed files with 9 additions and 8 deletions

View File

@ -1,6 +1,6 @@
import ./datastore/datastore
import ./datastore/fsds
import ./datastore/sql
# import ./datastore/sql
import ./datastore/mountedds
import ./datastore/tieredds

View File

@ -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)

View File

@ -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))

View File

@ -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"