Skip to content

Commit

Permalink
URI-encode "=" in query values for PostgreSQL (#95).
Browse files Browse the repository at this point in the history
  • Loading branch information
paurkedal committed Sep 20, 2022
1 parent f0decae commit 867049e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion caqti-driver-postgresql/lib/caqti_driver_postgresql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module Pg = Postgresql
let ( |>? ) r f = match r with Ok x -> f x | Error _ as r -> r
let ( %>? ) f g x = match f x with Ok y -> g y | Error _ as r -> r

let pct_encoder =
Uri.pct_encoder ~query_value:(`Custom (`Query_value, "", "=")) ()

module Int_hashable = struct
type t = int
let equal (i : int) (j : int) = i = j
Expand Down Expand Up @@ -170,7 +173,7 @@ module Pg_ext = struct
Error (Caqti_error.connect_rejected ~uri msg))
|>? fun (notice_processing, uri') ->
let conninfo =
if Uri.host uri <> None then Uri.to_string uri' else
if Uri.host uri <> None then Uri.to_string ~pct_encoder uri' else
let mkparam k v = k ^ " = '" ^ escaped_connvalue v ^ "'" in
let mkparams (k, vs) = List.map (mkparam k) vs in
String.concat " " (List.flatten (List.map mkparams (Uri.query uri')))
Expand Down

0 comments on commit 867049e

Please sign in to comment.