Closed SylvainBoilard closed 4 years ago
Hi @SylvainBoilard, can you give me a concrete example? not sure I follow. Doesn't using $?name
placeholder variables in the query and passing optional arguments as func ?optional ~other
solve your problem?
It does actually, I didn’t know I could use options using ?label
instead of ~label
when calling a function with optional arguments.
Thank you for your answer, and sorry for the noise.
No worries! glad that helped.
Hi,
I find using functions with optional parameters very unwieldy when it is not known in advance whether a parameter will be null or not, for example when parsing a JSON file where some values may be entirely omitted.
Currently I have resorted to changing the type of the generated functions with
Obj.magic
by turning any optional argument into a "mandatory" named argument with an option type (fortunately this works), and I think this is actually the best solution for me in the current state of affairs: I can then simply useNone
as parameter when inserting a record with aNULL
value, and I can do the actual insertion in one line of code.It would be great if I had the option to tell ppx_pgsql to directly generate functions that way.
Cheers,