Skip to content
Browse files

Sqlexpr_sqlite: fix type of select_one, wrap conversion exns in monad.

  • Loading branch information...
1 parent ee654cb commit 0ba73d13e2fe9ccd035b679254e9dbbc1033f1b9 @mfp committed
Showing with 4 additions and 3 deletions.
  1. +3 −2 sqlexpr_sqlite.ml
  2. +1 −1 sqlexpr_sqlite.mli
View
5 sqlexpr_sqlite.ml
@@ -440,7 +440,7 @@ struct
match Sqlite3.step stmt with
Sqlite3.Rc.ROW ->
check_num_cols "select" stmt expr >>
- lwt x = f (snd expr.get_data (Sqlite3.row_data stmt)) in
+ lwt x = try_lwt f (snd expr.get_data (Sqlite3.row_data stmt)) in
loop (x :: l)
| Sqlite3.Rc.DONE -> return (List.rev l)
| rc -> raise_error ~sql ~params db rc
@@ -455,7 +455,8 @@ struct
(fun stmt sql params ->
ensure_reset_stmt stmt begin fun () ->
match Sqlite3.step stmt with
- Sqlite3.Rc.ROW -> snd expr.get_data (Sqlite3.row_data stmt)
+ Sqlite3.Rc.ROW ->
+ try_lwt return (snd expr.get_data (Sqlite3.row_data stmt))
| Sqlite3.Rc.DONE -> M.fail Not_found
| rc -> raise_error ~sql ~params db rc
end ())
View
2 sqlexpr_sqlite.mli
@@ -89,7 +89,7 @@ sig
(** [select_one db expr ...] takes the first result from
[select db expr ...]. @raise Not_found if no row is found. *)
- val select_one : db -> ('c, 'a M.t, 'a M.t) expression -> 'c
+ val select_one : db -> ('c, 'a, 'a M.t) expression -> 'c
(** Run the provided function in a DB transaction. A rollback is performed
if an exception is raised inside the transaction. *)

0 comments on commit 0ba73d1

Please sign in to comment.
Something went wrong with that request. Please try again.