Commits

Dmitry Grebeniuk  committed 1290a57

/

  • Participants
  • Parent commits d5674bf

Comments (0)

Files changed (1)

File src/dbi/dbi_pg.ml

   }
 ;
 
-type make_comp_typer2 'r =
-(*
-  (P.result -> ~row:int -> ~col:int -> 'r) ->
-*)
-  comp_typer2 'r
-;
-
     module WC
      :
       sig
 
-value string : make_comp_typer2 string
+value string : comp_typer2 string
+;
+
+value number : comp_typer2 Decimal.t
 ;
 
       end
      =
       struct
 
-(*
-type make_comp_typer2 'a 'r =
-  ~want_ftype:string ->
-  ~get_it:(P.result -> ~row:int -> ~col:int -> 'a) ->
-  typer2 'r
-;
-*)
-
 value common get_it ~want_ftype =
   let want_ftype_notnull = want_ftype ^ " (not null)" in
   let typeerror ctw ~got =
   )
 ;
 
+value number = common
+  ~want_ftype:"number (numeric, decimal)"
+  (fun pres ~row ~col ->
+     let str = pres#getvalue row col in
+     let scale = pres#fmod row in
+     let () = failwith "WC.number: str=%S, scale=%i" str scale in
+     Decimal.of_string_scale str scale
+  )
+;
+
       end
     ;
 
 *)
 ;
 
+value { u_notnull = number ; u_nullable = number_opt } =
+  common WC.number
+    ~check_ftype: ( (=) P.NUMERIC )
+;
+
 
 type sql_t = [= `Null | `String of string ]
 ;
       rt ucg = Af2.run1 ucg rt
     ;
 
+
+
   end
 ;
 
       ]
     ;
 
+    method iter_uc ug = Q.(
+      let record_type = presult in
+      let cg = compile_getter record_type ug in
+      let ntup = presult#ntuples in
+      let rec inner i =
+        if i = ntup
+        then ()
+        else
+          let record = { rres = presult ; rrow = i } in
+          ( let () = Af.run cg record in inner (i + 1) )
+      in
+        inner 0
+    )
+    ;
+
 
 (*
     method fetchall_array () : array (array sql_t) = [| [|  |] |];