From 7f8b9ac403ff419f36279423ce1208baf0289cd3 Mon Sep 17 00:00:00 2001 From: Marc Biedermann Date: Fri, 26 Jan 2024 15:18:07 +0100 Subject: [PATCH] fix unused default option --- backend/mariadb_backend.ml | 13 ++++--------- backend/mariadb_utils.ml | 3 +-- backend/migrations.ml | 10 ++++++++++ lib/persistence.ml | 8 +------- test/main.ml | 6 +++--- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/backend/mariadb_backend.ml b/backend/mariadb_backend.ml index dfc5241..bd5e770 100644 --- a/backend/mariadb_backend.ml +++ b/backend/mariadb_backend.ml @@ -917,13 +917,11 @@ struct ] ;; - let default_where = Some "mark_as_deleted IS NULL" - let find_request_sql = Mariadb_utils.find_request_sql sql_select_columns - default_where table_name + ~default_where:None ~joins:"" ;; @@ -935,14 +933,11 @@ struct Entity.RoleAssignment.t ;; - let find_all_request ?default_where () = - find_request_sql ?default_where "" - |> Caqti_type.(unit ->* Entity.RoleAssignment.t) + let find_all_request = + find_request_sql "" |> Caqti_type.(unit ->* Entity.RoleAssignment.t) ;; - let find_all ?ctx ?default_where = - Database.collect ?ctx (find_all_request ?default_where ()) - ;; + let find_all ?ctx = Database.collect ?ctx find_all_request let find_all_by_role_request = find_request_sql {sql|WHERE role = ?|sql} diff --git a/backend/mariadb_utils.ml b/backend/mariadb_utils.ml index 4e2ae9d..a9f9203 100644 --- a/backend/mariadb_utils.ml +++ b/backend/mariadb_utils.ml @@ -1,8 +1,7 @@ let find_request_sql sql_select_columns - default_where table_name - ?(default_where = default_where) + ?(default_where = None) ?(count = false) ?(joins = "") where_fragment diff --git a/backend/migrations.ml b/backend/migrations.ml index 889a54a..4d3dd8b 100644 --- a/backend/migrations.ml +++ b/backend/migrations.ml @@ -237,6 +237,13 @@ let create_guardian_assign_roles_history_table = |sql} ;; +let remove_unused_mark_as_deleted_column = + {sql| + ALTER TABLE guardian_assign_roles + DROP COLUMN IF EXISTS mark_as_deleted + |sql} +;; + let all_tables = [ "guardian_actors" ; "guardian_actor_roles" @@ -301,5 +308,8 @@ let all = ; ( "create guardian assign roles history table" , "2024-01-18T16:01" , create_guardian_assign_roles_history_table ) + ; ( "remove unused mark as deleted column" + , "2024-01-26T15:00" + , remove_unused_mark_as_deleted_column ) ] ;; diff --git a/lib/persistence.ml b/lib/persistence.ml index ffc48a1..5101782 100644 --- a/lib/persistence.ml +++ b/lib/persistence.ml @@ -102,16 +102,10 @@ module type Backend = sig module RoleAssignment : sig val table_name : string val sql_select_columns : string list - - val find_request_sql - : ?default_where:string option - -> ?count:bool - -> string - -> string + val find_request_sql : ?count:bool -> string -> string val find_all : ?ctx:(string * string) list - -> ?default_where:string option -> unit -> role_assignment list Lwt.t diff --git a/test/main.ml b/test/main.ml index 99875bf..9ca1219 100644 --- a/test/main.ml +++ b/test/main.ml @@ -619,7 +619,7 @@ module Tests (Backend : Guard.PersistenceSig) = struct let%lwt () = let open Lwt in let open Backend.RoleAssignment in - find_all ?ctx ~default_where:None () + find_all ?ctx () >>= Lwt_list.iter_s (delete ?ctx ~comment:"[system] testing") in Lwt.return_unit @@ -649,7 +649,7 @@ module Tests (Backend : Guard.PersistenceSig) = struct let%lwt () = let open Lwt in let open Backend.RoleAssignment in - find_all ?ctx ~default_where:None () + find_all ?ctx () >>= Lwt_list.iter_s (delete ?ctx ~comment:"[system] testing") in Lwt.return_unit @@ -689,7 +689,7 @@ module Tests (Backend : Guard.PersistenceSig) = struct let%lwt () = let open Lwt in let open Backend.RoleAssignment in - find_all ?ctx ~default_where:None () + find_all ?ctx () >>= Lwt_list.iter_s (delete ?ctx ~comment:"[system] testing") in Lwt.return_unit