How to add dynamic types?

23 views
Skip to first unread message

Alex Druzhilov

unread,
Feb 17, 2015, 5:57:49 AM2/17/15
to epg...@googlegroups.com
For example this request returns error, because this data can't be encoded properly: 
>> epgsql:equery(C, "select $1::my_custom_type[]", [[<<"foo">>, <<"bar">>]])
{error,{error,error,<<"22P02">>, <<"array value must start with \"{\" or dimension information">>, []}}

But at the same time the information about this type is available:
>> epgsql:parse(C, "select $1::my_custom_type[]", [])
{ok,#statement{name = [],
                         columns = [#column{name = <<"my_custom_type">>,
                                                          type = {unknown_oid,28008},
                                                          size = -1,modifier = -1,format = 0}],
                         types = [{unknown_oid,28008}]}}

May be I didn't find proper approach how to do it?

David Welton

unread,
Feb 17, 2015, 9:52:04 AM2/17/15
to Alex Druzhilov, epg...@googlegroups.com
Currently I'm not sure there's a way to support user-supplied dynamic
types without hacking on the source code.

You'd need to add your type to update_type_cache(C) as well as the
epgsql_binary.erl file.

Ultimately, it would be cool if it were possible to do this at run time.
> --
> You received this message because you are subscribed to the Google Groups
> "Erlang epgsql Postgres driver use and development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to epgsql+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/
Reply all
Reply to author
Forward
0 new messages