aboutsummaryrefslogtreecommitdiff
path: root/lib/analysers
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-02-06 19:04:27 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-02-07 12:15:00 +0100
commit7a8d35a8a27f4492fbb021e583f30f9a96f10a25 (patch)
treebfdb989ed504944c293366b173a63dfd84343451 /lib/analysers
parent69d9b6ada15af41fa5db179f71c2bb284c643f96 (diff)
Corrected a bug when mixing plain and group filtersmain
Diffstat (limited to 'lib/analysers')
-rw-r--r--lib/analysers/filters.ml22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/analysers/filters.ml b/lib/analysers/filters.ml
index 15e8cda..cd47e27 100644
--- a/lib/analysers/filters.ml
+++ b/lib/analysers/filters.ml
@@ -36,9 +36,8 @@ let print :
let cte_index =
match cte.ImporterSyntax.CTE.group with
| Some expression ->
- begin
- if acc.has_previous then Chunk.add_string query ", "
- else Chunk.add_string query "WITH "
+ begin if acc.has_previous then Chunk.add_string query ", "
+ else Chunk.add_string query "WITH "
end;
Chunk.add_string query "filter";
Chunk.add_string query (string_of_int n);
@@ -59,13 +58,16 @@ let print :
Chunk.add_string query ".group_function"
end;
- begin
- match cte.ImporterSyntax.CTE.filters with
- | [] -> ()
- | _ ->
- Chunk.add_string query " WHERE ";
- Chunk.add_expressions ~sep:"\nAND " ~repr:(Printers.path ~conf)
- query cte.ImporterSyntax.CTE.filters
+ begin match cte.ImporterSyntax.CTE.filters with
+ | [] -> ()
+ | _ ->
+ (* If there is a previous group, just add the AND clause in the query *)
+ let () =
+ if not acc.has_previous then Chunk.add_string query " WHERE "
+ else Chunk.add_string query " AND "
+ in
+ Chunk.add_expressions ~sep:"\nAND " ~repr:(Printers.path ~conf)
+ query cte.ImporterSyntax.CTE.filters
end;
Chunk.add_string query ")\n";
Some acc.n