Inserting a boolean value into an sqlite3 database throws an exception. Removing the boolean field fixes the problem.
Error message
Fatal error: exception Failure("wrapped value list did not conform to specification - expected BOOLEAN got BOOLEAN")
Example program
open Petrol
open Petrol.Sqlite3
let db = StaticSchema.init ()
let todo, Expr.[title; desc; finished] =
StaticSchema.declare_table db ~name:"todo"
Schema.
[ field "title" ~ty:Type.text
; field "desc" ~ty:Type.text
; field "finished" ~ty:Type.bool ]
let insert_todo ~title:t ~desc:d ~finished:fn db =
Query.insert ~table:todo
~values:Expr.[title := s t; desc := s d; finished := bl fn]
|> Request.make_zero |> Petrol.exec db
let test_insert =
let open Lwt_result.Syntax in
let* conn = Caqti_lwt.connect (Uri.of_string "sqlite3://::memory:") in
let* _ = Petrol.StaticSchema.initialise db conn in
insert_todo ~title:"use petrol" ~desc:"it seems amazing" ~finished:true conn
let () =
match Lwt_main.run test_insert with
| Ok _ ->
print_endline "ok"
| Error err ->
print_endline (Caqti_error.show err)
Dune
(executable
(name todo)
(libraries petrol caqti-driver-sqlite3))
Inserting a boolean value into an sqlite3 database throws an exception. Removing the boolean field fixes the problem.
Error message
Example program
Dune
Setup