pgx icon indicating copy to clipboard operation
pgx copied to clipboard

pgtype: enable deep copy of pgtype.Map

Open ZhouXing19 opened this issue 1 year ago • 1 comments

I would like to design a "clone" connection function in my program, which takes a parent connection, and run pgx.ConnectConfig() with the same config of the parent connection, and also deep copy the type map of the parent connection.

However, I can't find a way to do such a deep copy, as none of Map.oidToType or nameToType and etc are exported.

So I wonder if we can implement a method like func (m *Map) Clone() Map, or just simply make these not-exported field accessible so that i can loop over entries inside each map.

ZhouXing19 avatar Aug 27 '24 18:08 ZhouXing19

See https://github.com/jackc/pgx/pull/2048 for some discussion of copying type maps.

jackc avatar Aug 27 '24 22:08 jackc