summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-18 18:21:13 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-18 18:21:13 +0100
commit7087a0c2c84e796e474784cbd28d4a4e574cf2c0 (patch)
tree2cf3d4be465830726668f344378dc1771f57168c /test
parent7b5baa29818c9fe6e33d50c8458aa2824274158e (diff)
Updated to latest Caqti library
Diffstat (limited to 'test')
-rw-r--r--test/common.ml16
-rw-r--r--test/schema.ml2
2 files changed, 11 insertions, 7 deletions
diff --git a/test/common.ml b/test/common.ml
index f06d431..0ef5cb3 100644
--- a/test/common.ml
+++ b/test/common.ml
@@ -6,7 +6,11 @@ let ( let* ) = Lwt.bind
configuration *)
let connect : Configuration.Ast.setting -> Caqti_lwt.connection Lwt.t =
fun conf ->
- let* conn = Caqti_lwt_unix.connect (Uri.of_string "sqlite3::memory:") in
+ (* Pin the driver tweaks below 1.8 so that the sqlite3 driver does not turn
+ on PRAGMA foreign_keys: the tests insert references to rows that are not
+ present in the referenced table. *)
+ let config = Caqti.Connect.Config.(set tweaks_version (1, 7) default) in
+ let* conn = Caqti_lwt_unix.connect ~config (Uri.of_string "sqlite3::memory:") in
let* db = Caqti_lwt.or_fail conn in
let module Db = (val db) in
let* () = Query.create db conf in
@@ -14,7 +18,7 @@ let connect : Configuration.Ast.setting -> Caqti_lwt.connection Lwt.t =
(** Load the given content and return the values as a json *)
let content_as_json :
- 'a Model.Content.t -> (int64, string, [ `One ]) Caqti_request.t =
+ 'a Model.Content.t -> (int64, string, [ `One ]) Caqti.Template.Request.t =
fun content ->
let fields =
Model.Content.fields content
@@ -46,15 +50,15 @@ let content_as_json :
in
let q = Buffer.contents buff in
- Caqti_request.Infix.(Caqti_type.(int64) ->! Caqti_type.string)
- ~oneshot:true
+ let open Caqti.Templater in
+ direct T.(int64 -->! string)
("SELECT json_object(" ^ q ^ ") from " ^ Model.Content.id content
^ " where id=?")
let query_values (table : Model.Reference.t Model.Content.t) (feature : string)
=
- Caqti_request.Infix.(Caqti_type.(int64) ->* Caqti_type.string)
- ~oneshot:true
+ let open Caqti.Templater in
+ direct T.(int64 -->* string)
("SELECT json_object('" ^ feature ^ "', target) from \""
^ Model.Content.id table ^ "." ^ feature ^ "\" where parent=?")
diff --git a/test/schema.ml b/test/schema.ml
index b063270..3b52812 100644
--- a/test/schema.ml
+++ b/test/schema.ml
@@ -14,7 +14,7 @@ let ( let* ) = Lwt.bind
let ( let+ ) opt cont = Result.map cont opt
let schema_query =
- Caqti_request.Infix.(Caqti_type.(string) ->! Caqti_type.string)
+ Caqti.Templater.static Caqti.Templater.T.(string -->! string)
"SELECT sql from sqlite_schema where name=?"
let get_schema : Caqti_lwt.connection -> string -> string Lwt.t =