Detect unsafe pgtype.DriverBytes usage
Add test for unsafe usage and test for correct usage that ensures driver memory is actually used.
This commit is contained in:
@@ -79,6 +79,13 @@ func (r *connRow) Scan(dest ...interface{}) (err error) {
|
||||
return rows.Err()
|
||||
}
|
||||
|
||||
for _, d := range dest {
|
||||
if _, ok := d.(*pgtype.DriverBytes); ok {
|
||||
rows.Close()
|
||||
return fmt.Errorf("cannot scan into *pgtype.DriverBytes from QueryRow")
|
||||
}
|
||||
}
|
||||
|
||||
if !rows.Next() {
|
||||
if rows.Err() == nil {
|
||||
return ErrNoRows
|
||||
|
||||
Reference in New Issue
Block a user