Skip to content

Commit

Permalink
Get rid of Pgx_aux
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanlong committed May 8, 2020
1 parent 209bc7e commit 163017b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 121 deletions.
1 change: 0 additions & 1 deletion pgx/src/error_response.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
open Printf
open Sexplib0.Sexp_conv
open Pgx_aux

type t =
{ code : string
Expand Down
8 changes: 4 additions & 4 deletions pgx/src/pgx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*)

open Pgx_aux
open Printf
open Sexplib0.Sexp_conv
include Types
Expand Down Expand Up @@ -810,7 +808,9 @@ module Make (Thread : Io) = struct
| Message_in.CommandComplete _ -> loop ()
| Message_in.EmptyQueryResponse -> loop ()
| Message_in.DataRow fields ->
List.map (Option.bind Value.of_string) fields |> f >>= loop
ListLabels.map ~f:(fun f -> Option.bind f Value.of_string) fields
|> f
>>= loop
| Message_in.NoData -> loop ()
| Message_in.ParameterStatus _ ->
(* 43.2.6: ParameterStatus messages will be generated whenever
Expand Down Expand Up @@ -969,7 +969,7 @@ module Make (Thread : Io) = struct
| _, Message_in.CopyData row -> loop acc ([ row |> Value.of_string ] :: rows) state
| _, Message_in.CopyDone -> loop acc rows state
| `Rows, Message_in.DataRow row ->
let row = List.map (Option.bind Value.of_string) row in
let row = List.map (fun f -> Option.bind f Value.of_string) row in
loop acc (row :: rows) `Rows
| (`Row_desc | `Rows), Message_in.CommandComplete _ ->
let rows = List.rev rows in
Expand Down
79 changes: 0 additions & 79 deletions pgx/src/pgx_aux.ml

This file was deleted.

31 changes: 0 additions & 31 deletions pgx/src/pgx_aux.mli

This file was deleted.

10 changes: 5 additions & 5 deletions pgx/src/pgx_value.ml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
open Sexplib0.Sexp_conv
open Pgx_aux

let compare_float = Float.compare
let compare_int = Int.compare
let compare_option = Stdlib.Option.compare
let compare_list = Base.compare_list
let compare_string = String.compare

type v = string [@@deriving compare, sexp_of]
type t = v option [@@deriving compare, sexp_of]
Expand All @@ -26,7 +26,7 @@ let required f = function
| None -> raise (Conversion_failure "Expected not-null but got null")
;;

let opt = Option.bind
let opt f v = Option.bind v f
let null = None

let of_binary b =
Expand Down Expand Up @@ -105,7 +105,7 @@ let of_hstore hstore =
in
key_str ^ "=>" ^ value_str
in
Some (String.join ", " (List.map string_of_mapping hstore))
Some (String.concat ", " (List.map string_of_mapping hstore))
;;

let to_hstore' str =
Expand All @@ -116,7 +116,7 @@ let to_hstore' str =
let parse_quoted stream =
let rec loop accum stream =
match Stream.next stream with
| '"' -> String.implode (List.rev accum)
| '"' -> Base.String.of_char_list (List.rev accum)
(* FIXME: Slashes don't seem to round-trip properly *)
| '\\' -> loop (Stream.next stream :: accum) stream
| x -> loop (x :: accum) stream
Expand Down Expand Up @@ -287,7 +287,7 @@ let to_list' str =
Buffer.add_char buf x;
accum, quoted, false
in
let accum, _, _ = String.fold_left loop ([], false, false) str in
let accum, _, _ = Base.String.fold ~f:loop ~init:([], false, false) str in
let accum = if Buffer.length buf = 0 then accum else add_field accum in
List.rev accum
;;
Expand Down
1 change: 0 additions & 1 deletion pgx/test/test_pgx_value.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
open Pgx_aux
open Printf
open Sexplib0
open Sexplib0.Sexp_conv
Expand Down

0 comments on commit 163017b

Please sign in to comment.