diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/analysers/filters.ml | 22 |
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 |
