From 4af7d2f6ff8b38365c97a89c295710f5ed3266f5 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 30 Mar 2026 17:56:42 +0200 Subject: Manage insertion for multireferences fields --- lib/model/typ.ml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/model/typ.ml') diff --git a/lib/model/typ.ml b/lib/model/typ.ml index 2770885..d736be0 100644 --- a/lib/model/typ.ml +++ b/lib/model/typ.ml @@ -12,7 +12,7 @@ type ('db, 't) t = | Text : (string option, 't) t | Integer : (int64 option, 't) t | MonoReference : 't reference -> (int64 option, 't) t - | MultiReference : 't reference -> (int64 option, 't) t + | MultiReference : 't reference -> (int64, 't) t (** Multireferences properties allows only one kind of content. They are not encoded in the content table but in another table *) @@ -28,8 +28,8 @@ let map : type a. ('ref1 -> 'ref2) -> (a, 'ref1) t -> (a, 'ref2) t = let default_value : type a. (a, _) t -> a = function | Integer -> None | Text -> None - | MultiReference _ -> None | MonoReference _ -> None + | MultiReference _ -> raise Not_found let eq : type a b c. (a, c) t -> (b, c) t -> (a, b) Type.eq option = fun t1 t2 -> @@ -56,7 +56,9 @@ Example for inserting data *) type 't value = - | V : ('a option, 't) t * 'a -> 't value + | None (** None tell the field is empty in the database *) + | V : ('a option, 't) t * 'a option -> 't value (** V is the value for the field. The field type is also reported in order to give the compiler the nature of the data *) - | None (** None tell the field is empty in the database *) + | Seq : (int64, 't) t * int64 Seq.t -> 't value + (** Get a sequence of values for a multivaluated field *) -- cgit v1.2.3