From 7087a0c2c84e796e474784cbd28d4a4e574cf2c0 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Wed, 18 Nov 2026 18:21:13 +0100 Subject: Updated to latest Caqti library --- test/common.ml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'test/common.ml') 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=?") -- cgit v1.2.3