2
0

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:
Jack Christensen
2022-02-26 20:23:35 -06:00
parent b1e4b96e6c
commit ffc5a692cb
2 changed files with 46 additions and 6 deletions
+7
View File
@@ -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