param count, name, index
This commit is contained in:
16
test/test.kk
16
test/test.kk
@@ -10,17 +10,17 @@ tail fun do-while(f: () -> <div|e> maybe<a>): <div|e> a
|
||||
Nothing -> do-while(f)
|
||||
Just(r) -> r
|
||||
|
||||
fun stmt(db: sqlite3, sql: string, bind: maybe<string> = Nothing)
|
||||
fun stmt(db: sqlite3, sql: string, bind: list<(string, string)> = Nil)
|
||||
println(sql)
|
||||
match db.prepare(sql.slice)
|
||||
Left(r-prep) -> println(" prepare result: " ++ r-prep.show)
|
||||
Right((stmt, rest)) ->
|
||||
println(" prepare remainder: " ++ rest.show)
|
||||
match bind
|
||||
Nothing -> ()
|
||||
Just(text) ->
|
||||
val r = stmt.bind-text(1, text)
|
||||
println(" bind result: " ++ r.show)
|
||||
println(" param count: " ++ stmt.param-count.show)
|
||||
bind.foreach() fn((name, text))
|
||||
val idx = stmt.param-index(name)
|
||||
val r = stmt.bind-text(idx, text)
|
||||
println(" bind " ++ name ++ " result: " ++ r.show)
|
||||
val r-step = do-while
|
||||
val r = stmt.step
|
||||
match r
|
||||
@@ -29,7 +29,7 @@ fun stmt(db: sqlite3, sql: string, bind: maybe<string> = Nothing)
|
||||
println(" col " ++ i.show ++ ": " ++ stmt.text(i))
|
||||
Nothing
|
||||
r -> Just(r)
|
||||
println(" final step result: " ++ r-step.show)
|
||||
println(" final step result: " ++ r-step.show)
|
||||
val r-fin = stmt.finalize
|
||||
println(" finalize result: " ++ r-fin.show)
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fun main()
|
||||
println("open result: " ++ r-open.show)
|
||||
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 (?);", Just("value inserted from koka"))
|
||||
stmt(db, "INSERT INTO koka VALUES (?1);", [("?1", "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