Skip to content

Commit

Permalink
Sqlexpr_sqlite_lwt: bind all the params in a single detach op.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfp committed Jan 25, 2011
1 parent 0c09b34 commit 16d6ced
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sqlexpr_sqlite_lwt.ml
Expand Up @@ -227,10 +227,15 @@ struct
failwithfmt "Error with SQL statement %S:\n%s" sql (Printexc.to_string e)
in
(* the list of params is reversed *)
iteri
(fun n v -> check_ok ~sql ~stmt worker
(fun _ -> (Stmt.bind stmt (nparams - n))) v)
params >>
detach worker
(fun dbh stmt ->
let n = ref nparams in
List.iter
(fun v -> match Stmt.bind stmt !n v with
Sqlite3.Rc.OK -> decr n
| code -> do_raise_error ~sql ~params code)
params)
stmt >>
try_lwt
f (worker, stmt) sql params
finally
Expand Down

0 comments on commit 16d6ced

Please sign in to comment.