diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-11-18 18:21:13 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-11-18 18:21:13 +0100 |
| commit | 7087a0c2c84e796e474784cbd28d4a4e574cf2c0 (patch) | |
| tree | 2cf3d4be465830726668f344378dc1771f57168c /test/common.ml | |
| parent | 7b5baa29818c9fe6e33d50c8458aa2824274158e (diff) | |
Updated to latest Caqti library
Diffstat (limited to 'test/common.ml')
| -rw-r--r-- | test/common.ml | 16 |
1 files changed, 10 insertions, 6 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=?") |
