From c284321b1073e06481c63e2c061a1600fa68254d Mon Sep 17 00:00:00 2001
From: Sébastien Dailly <sebastien@dailly.me>
Date: Thu, 10 Apr 2025 20:27:59 +0200
Subject: Added filters expressions in the externals

---
 lib/syntax/importerSyntax.ml  | 25 ++++++++++++++-----------
 lib/syntax/importerSyntax.mli |  2 +-
 2 files changed, 15 insertions(+), 12 deletions(-)

(limited to 'lib/syntax')

diff --git a/lib/syntax/importerSyntax.ml b/lib/syntax/importerSyntax.ml
index cfbba81..d91db09 100644
--- a/lib/syntax/importerSyntax.ml
+++ b/lib/syntax/importerSyntax.ml
@@ -14,13 +14,18 @@ let toml_of_table Table.{ file; tab; name } =
 
   Otoml.table values
 
+let repr_expression_list ~repr l =
+  Otoml.array
+    (List.map l ~f:(fun v ->
+         Otoml.string (ImportExpression.Repr.repr ~top:true repr v)))
+
 module Extern = struct
   type t = {
     intern_key : Path.t E.t;
     target : Table.t;
     extern_key : Path.column E.t;
     allow_missing : bool;
-    match_rule : string option;
+    filters : ImportDataTypes.Path.column ImportExpression.T.t list;
   }
   [@@deriving show, eq]
   (** Describe a relation beteween two tables *)
@@ -38,6 +43,10 @@ module Extern = struct
                extern.extern_key );
         ("file", Otoml.string extern.target.file);
         ("allow_missing", Otoml.boolean extern.allow_missing);
+        ( "filters",
+          repr_expression_list
+            ~repr:(fun s -> ":" ^ Path.column_to_string s)
+            extern.filters );
       ]
     in
 
@@ -66,19 +75,13 @@ type t = {
 }
 
 let repr t =
-  let repr_expression_list l =
-    Otoml.array
-      (List.map l ~f:(fun v ->
-           Otoml.string (ImportExpression.Repr.repr ~top:true Path.show v)))
-  in
-
   let sheet =
     Otoml.table
       [
-        ("columns", repr_expression_list t.columns);
-        ("filters", repr_expression_list t.filters);
-        ("sort", repr_expression_list t.sort);
-        ("uniq", repr_expression_list t.uniq);
+        ("columns", repr_expression_list ~repr:Path.show t.columns);
+        ("filters", repr_expression_list ~repr:Path.show t.filters);
+        ("sort", repr_expression_list ~repr:Path.show t.sort);
+        ("uniq", repr_expression_list ~repr:Path.show t.uniq);
       ]
   in
 
diff --git a/lib/syntax/importerSyntax.mli b/lib/syntax/importerSyntax.mli
index 49b7364..47dabe6 100644
--- a/lib/syntax/importerSyntax.mli
+++ b/lib/syntax/importerSyntax.mli
@@ -4,7 +4,7 @@ module Extern : sig
     target : ImportDataTypes.Table.t;
     extern_key : ImportDataTypes.Path.column ImportExpression.T.t;
     allow_missing : bool;
-    match_rule : string option;
+    filters : ImportDataTypes.Path.column ImportExpression.T.t list;
   }
   [@@deriving show, eq]
 end
-- 
cgit v1.2.3