Add basic tuple and value fetching from queries.
Add safeties for =destroy hooks. FossilOrigin-Name: 2fae5297a0d0598cc3580777688b4f4307de008d4f379d2fb224c8a74cb9b708
This commit is contained in:
parent
1ed442a68a
commit
7850a79372
14 changed files with 237 additions and 17 deletions
19
tests/tuples/t_can_be_stringified.nim
Normal file
19
tests/tuples/t_can_be_stringified.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# vim: set et sta sw=4 ts=4 :
|
||||
|
||||
discard """
|
||||
output: "okay!"
|
||||
"""
|
||||
|
||||
import kuzu
|
||||
|
||||
let db = newKuzuDatabase()
|
||||
let conn = db.connect
|
||||
|
||||
var q = conn.query( "CREATE NODE TABLE Doop ( id SERIAL, thing STRING, PRIMARY KEY(id) )" )
|
||||
q = conn.query( "CREATE (d:Doop {thing: 'okay!'})" )
|
||||
q = conn.query( "MATCH (d:Doop) RETURN d.thing" )
|
||||
|
||||
var tup = q.getNext
|
||||
|
||||
echo $tup
|
||||
|
||||
17
tests/tuples/t_throws_exception_fetching_at_end.nim
Normal file
17
tests/tuples/t_throws_exception_fetching_at_end.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# vim: set et sta sw=4 ts=4 :
|
||||
|
||||
import
|
||||
std/re
|
||||
import kuzu
|
||||
|
||||
let db = newKuzuDatabase()
|
||||
let conn = db.connect
|
||||
|
||||
var q = conn.query( "CREATE NODE TABLE Doop ( id SERIAL, thing STRING, PRIMARY KEY(id) )" )
|
||||
q = conn.query( "MATCH (d:Doop) RETURN d.thing" )
|
||||
|
||||
try:
|
||||
discard q.getNext
|
||||
except KuzuQueryException as err:
|
||||
assert err.msg.contains( re"""Unable to fetch next tuple.""" )
|
||||
|
||||
20
tests/tuples/t_throws_exception_invalid_index.nim
Normal file
20
tests/tuples/t_throws_exception_invalid_index.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# vim: set et sta sw=4 ts=4 :
|
||||
|
||||
import
|
||||
std/re
|
||||
import kuzu
|
||||
|
||||
let db = newKuzuDatabase()
|
||||
let conn = db.connect
|
||||
|
||||
var q = conn.query( "CREATE NODE TABLE Doop ( id SERIAL, thing STRING, PRIMARY KEY(id) )" )
|
||||
q = conn.query( "CREATE (d:Doop {thing: 'okay!'})" )
|
||||
q = conn.query( "MATCH (d:Doop) RETURN d.thing" )
|
||||
|
||||
let tup = q.getNext
|
||||
|
||||
try:
|
||||
echo tup[22]
|
||||
except KuzuIndexException as err:
|
||||
assert err.msg.contains( re"""Unable to fetch tuple value at idx 22.""" )
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue