[Ur] Need help with desugaring dml
Sergey Mironov
grrwlf at gmail.com
Sat Feb 11 03:18:58 EST 2017
Hi. I'm trying (again) to write an Ur/Web module to provide API for
managing OS-level processes. I expect users to pass it a table
containing _at_least_ id, process command name, arguments, placeholder
for exit code and status string. It is expected that users will use
tables containing more problem-specific columns.
The problem is that I cant use simple dml operations anymore. As a
start, I tried to write dummy insert using [demo/more/orm.ur] as
example, but was stopped by difficult [ensql] function. Could you
please help me to implement it? The code is quite short and listed
below.
Regards,
Sergey
---
con jobinfo = [
Id = int
, ExitCode = option int
, Cmd = string
, Hint = string
]
functor Make(M : sig
con u
constraint [Id,ExitCode,Cmd,Hint] ~ u
table t : (jobinfo ++ u)
sequence s
end) = struct
open CallbackFFI
type row' = record (jobinfo ++ M.u)
(* fun ensql [avail ::_] (r : row') : $(map (sql_exp avail [] []) fs') = *)
(* @map2 [meta] [fst] [fn ts :: (Type * Type) => sql_exp avail
[] [] ts.1] *)
(* (fn [ts] meta v => @sql_inject meta.Inj v) *)
(* M.folder M.cols r *)
(* createSync will start the job, but in this example it just does a
simple insert.
args is a problem-specific part of the table record.
How to make this dml(insert..) work? *)
fun createSync (ji : record jobinfo, args : record M.u) :
transaction (option int) =
i <- nextval M.s;
dml(insert M.t ({Id = sql_inject ji.Id,
ExitCode = sql_inject ji.ExitCode,
Cmd = sql_inject ji.Cmd,
Hint = sql_inject ji.Hint} ++ (ensql args) ));
return (Some i)
end
More information about the Ur
mailing list