Fix scanning json column into **string
refs https://github.com/jackc/pgx/issues/1470
This commit is contained in:
+14
-3
@@ -95,11 +95,22 @@ func (JSONCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan
|
||||
// https://github.com/jackc/pgx/issues/1418
|
||||
case sql.Scanner:
|
||||
return &scanPlanSQLScanner{formatCode: format}
|
||||
|
||||
default:
|
||||
return scanPlanJSONToJSONUnmarshal{}
|
||||
}
|
||||
|
||||
// This is to fix **string scanning. It seems wrong to special case sql.Scanner and pointer to pointer, but it's not
|
||||
// clear what a better solution would be.
|
||||
//
|
||||
// https://github.com/jackc/pgx/issues/1470
|
||||
if wrapperPlan, nextDst, ok := TryPointerPointerScanPlan(target); ok {
|
||||
if nextPlan := m.planScan(oid, format, nextDst); nextPlan != nil {
|
||||
if _, failed := nextPlan.(*scanPlanFail); !failed {
|
||||
wrapperPlan.SetNext(nextPlan)
|
||||
return wrapperPlan
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return scanPlanJSONToJSONUnmarshal{}
|
||||
}
|
||||
|
||||
type scanPlanAnyToString struct{}
|
||||
|
||||
Reference in New Issue
Block a user