mirror of https://github.com/jackc/pgx.git
Fix: Prefer sql.Scanner before TryWrapScanPlanFuncs
This was already the case when the data type was unknown but should also be the case when it is known.pull/1511/head
parent
c2e278e5d4
commit
a6ace8969b
|
@ -1239,9 +1239,11 @@ func (m *Map) planScan(oid uint32, formatCode int16, target any) ScanPlan {
|
|||
// defined on a type that could be unwrapped such as `type myString string`.
|
||||
//
|
||||
// https://github.com/jackc/pgtype/issues/197
|
||||
if dt == nil {
|
||||
if _, ok := target.(sql.Scanner); ok {
|
||||
if _, ok := target.(sql.Scanner); ok {
|
||||
if dt == nil {
|
||||
return &scanPlanSQLScanner{formatCode: formatCode}
|
||||
} else {
|
||||
return &scanPlanCodecSQLScanner{c: dt.Codec, m: m, oid: oid, formatCode: formatCode}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1260,10 +1262,6 @@ func (m *Map) planScan(oid uint32, formatCode int16, target any) ScanPlan {
|
|||
if _, ok := target.(*any); ok {
|
||||
return &pointerEmptyInterfaceScanPlan{codec: dt.Codec, m: m, oid: oid, formatCode: formatCode}
|
||||
}
|
||||
|
||||
if _, ok := target.(sql.Scanner); ok {
|
||||
return &scanPlanCodecSQLScanner{c: dt.Codec, m: m, oid: oid, formatCode: formatCode}
|
||||
}
|
||||
}
|
||||
|
||||
return &scanPlanFail{m: m, oid: oid, formatCode: formatCode}
|
||||
|
|
Loading…
Reference in New Issue