Skip to content

Commit

Permalink
fix unused default option
Browse files Browse the repository at this point in the history
  • Loading branch information
mabiede committed Jan 26, 2024
1 parent 5231409 commit 7f8b9ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
13 changes: 4 additions & 9 deletions backend/mariadb_backend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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:""
;;

Expand All @@ -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}
Expand Down
3 changes: 1 addition & 2 deletions backend/mariadb_utils.ml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions backend/migrations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 )
]
;;
8 changes: 1 addition & 7 deletions lib/persistence.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions test/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7f8b9ac

Please sign in to comment.