Commits

Anonymous committed eb8fe78

.

  • Participants
  • Parent commits 2d1aec2

Comments (0)

Files changed (1)

File src/dbi/dbi_pg.ml

 
   |  `Bool of bool
   |  `Int of int      (* smallint *)
-  |  `Int32 of int32  (* int *)
-  |  `Int64 of int64  (* bigint *)
-  |  `Num of Decimal.t  (* numeric/decimal *)
+  |  `Int32 of int32  (* int, serial *)
+  |  `Int64 of int64  (* bigint, bigserial *)
+  |  `Num of Decimal.t  (* numeric, decimal *)
 
   |  `Date of string
   |  `Time of string
 module WC
  :
   sig
-
-    value string : comp_typer2 string
-    ;
-
-    value number : comp_typer2 Decimal.t
-    ;
-
+    value string : comp_typer2 string;
+    value number : comp_typer2 Decimal.t;
+    value int64 : comp_typer2 int64;
   end
  =
   struct
       )
     ;
 
+    value int64 = common
+      ~want_ftype:"int64 (bigint, bigserial)"
+      (fun pres ~row ~col ->
+         let str = pres#getvalue row col in
+         try
+           Int64.of_string str
+         with
+         [ Failure "int_of_string" -> raise (Etype "int64" str)
+         ]
+      )
+    ;
+
   end
 ;
 
     value number_opt : ident -> uncomp_getter (option Decimal.t)
     ;
 
+    value int64 : ident -> uncomp_getter int64
+    ;
+
+    value int64_opt : ident -> uncomp_getter (option int64)
+    ;
+
 (*
     value sql_t : ident -> uncomp_getter sql_t
     ;
         ~check_ftype: ( (=) P.NUMERIC )
     ;
 
+    value { u_notnull = int64 ; u_nullable = int64_opt } =
+      common WC.int64
+        ~check_ftype: ( (=) P.INT8 )
+    ;
+
 
 (*
     value (sql_t : record -> ~col:int -> sql_t) record ~col =