jackc / pgx

PostgreSQL driver and toolkit for Go
MIT License
10.81k stars 842 forks source link

pgtype: enable deep copy of pgtype.Map #2116

Open ZhouXing19 opened 2 months ago

ZhouXing19 commented 2 months ago

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.

jackc commented 2 months ago

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