Skip to content

fix: add Conn and *Conn to mapperFor and isUnsafe type switches#993

Open
itxaiohanglover wants to merge 1 commit into
jmoiron:masterfrom
itxaiohanglover:fix/mapper-for-conn
Open

fix: add Conn and *Conn to mapperFor and isUnsafe type switches#993
itxaiohanglover wants to merge 1 commit into
jmoiron:masterfrom
itxaiohanglover:fix/mapper-for-conn

Conversation

@itxaiohanglover

Copy link
Copy Markdown

Summary

mapperFor() and isUnsafe() were missing Conn and *Conn cases in their type switches. When creating a Stmt from a *sqlx.Conn, the custom reflectx.Mapper was not propagated — it fell through to the default mapper().

This adds Conn and *Conn to both type switches, matching the existing handling for DB and Tx.

Fixes #975

Background

Conn has the same unsafe and Mapper fields as DB and Tx, but was overlooked when the type switches were written. PR #992 previously addressed this but was closed by the author due to lack of maintainer engagement.

Test plan

  • mapperFor(conn) returns conn.Mapper instead of the default mapper
  • isUnsafe(conn) returns conn.unsafe instead of false
  • Existing tests pass

Conn was missing from the type switches in mapperFor() and isUnsafe(),
causing custom Mapper and unsafe flag to not propagate when creating
Stmts from *sqlx.Conn.

Fixes jmoiron#975
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.

The reflectx.Mapper from conn cannot be passed to stmt when creating stmt from conn

1 participant