Skip to content

Commit 3235c59

Browse files
author
Jan Rochel
committed
use UPDATE for [set] instead of INSERT
1 parent 2c61c8a commit 3235c59

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/extensions/ocsipersist-pgsql/ocsipersist.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
(** PostgreSQL (>= 9.5) backend for Ocsipersist. *)
2+
13
let section = Lwt_log.Section.make "ocsipersist:sql"
24

35
module Lwt_thread = struct
@@ -95,7 +97,8 @@ let get p = use_pool @@ fun db ->
9597
Lwt.map (unmarshal @. one) (exec db query [p.name])
9698

9799
let set p v = use_pool @@ fun db ->
98-
insert db p.store p.name v
100+
let query = sprintf "UPDATE %s SET value = $2 WHERE key = $1 " p.store
101+
in exec db query [p.name; marshal v] >> Lwt.return ()
99102

100103
type 'value table = string
101104

0 commit comments

Comments
 (0)