jackc / jackc/pgx

pgtype: enable deep copy of pgtype.Map

Open
#2,116 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
14.3k
Forks
1.1k
Avg merge
6d 9h
Merged PRs (30d)
11

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start at the pgtype.Map entry point and inspect its unexported type maps and related state. Decide whether Clone should return an independent deep copy or expose internals, then add coverage demonstrating that changes to the clone do not affect the original.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.