Skip to content

feat: add opt-in PostgreSQL BYTEA preservation - #223

Merged
trakhimenok merged 2 commits into
mainfrom
preserve-postgres-binary
Oct 7, 2026
Merged

trakhimenok merged 2 commits into
mainfrom
preserve-postgres-binary

Conversation

@trakhimenok

Copy link
Copy Markdown
Contributor

PostgreSQL map-backed reads currently turn []byte results into strings, which corrupts BYTEA containing invalid UTF-8 when an API serializes the result. This adds opt-in DbOptions.PreserveBinaryValues; it retains copied byte slices only for PostgreSQL columns whose driver metadata reports BYTEA. The zero value and all other column types keep their existing behavior. Map-backed Get/GetMulti use the same path; recordset reads already preserve byte slices.

Validation: go test ./... -count=1, go vet ./..., and golangci-lint run ./... pass through wb run. Tests cover binary NUL/invalid UTF-8, empty versus NULL values, text/default compatibility, recordset reads, and owned copies.

@trakhimenok
trakhimenok merged commit 549ea5f into main Oct 7, 2026
5 checks passed
@trakhimenok
trakhimenok deleted the preserve-postgres-binary branch October 7, 2026 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant