get column values
This commit is contained in:
23
test/test.kk
23
test/test.kk
@@ -5,14 +5,26 @@ import sqlite/sqlite3
|
||||
// TODO(zephyr): For now, we're just doing a very basic test to estimate whether
|
||||
// I'm doing Koka FFI correctly. An actual test suite would be excellent.
|
||||
|
||||
fun stmt(db: sqlite3, text: string)
|
||||
println(text)
|
||||
match db.prepare(text.slice)
|
||||
tail fun do-while(f: () -> <div|e> maybe<a>): <div|e> a
|
||||
match f()
|
||||
Nothing -> do-while(f)
|
||||
Just(r) -> r
|
||||
|
||||
fun stmt(db: sqlite3, sql: string)
|
||||
println(sql)
|
||||
match db.prepare(sql.slice)
|
||||
Left(r-prep) -> println(" prepare result: " ++ r-prep.show)
|
||||
Right((stmt, rest)) ->
|
||||
println(" prepare remainder: " ++ rest.show)
|
||||
val r-step = stmt.step
|
||||
println(" step result: " ++ r-step.show)
|
||||
val r-step = do-while
|
||||
val r = stmt.step
|
||||
match r
|
||||
Row ->
|
||||
for(stmt.column-count) fn(i)
|
||||
println(" col " ++ i.show ++ ": " ++ stmt.text(i))
|
||||
Nothing
|
||||
r -> Just(r)
|
||||
println(" final step result: " ++ r-step.show)
|
||||
val r-fin = stmt.finalize
|
||||
println(" finalize result: " ++ r-fin.show)
|
||||
|
||||
@@ -23,5 +35,6 @@ pub fun main()
|
||||
stmt(db, "DROP TABLE IF EXISTS koka; -- reset previous test runs")
|
||||
stmt(db, "CREATE TABLE koka(v TEXT NOT NULL)")
|
||||
stmt(db, "INSERT INTO koka VALUES ('value inserted from koka');")
|
||||
stmt(db, "SELECT * FROM koka")
|
||||
val r-close = db.close
|
||||
println("close result: " ++ r-close.show)
|
||||
|
||||
Reference in New Issue
Block a user