Closed vetcher closed 1 year ago
I pushed a bug for the crash with reflection, but I don't think that calling Scan
on a pointer to a sql.Scanner
is going to work. It doesn't crash now, but it won't call Scan
for vPtr
.
It may be possible to restore the pre v1.12.0 -- assuming it did actually call it then (I didn't check) -- though all that reflection is pretty scary -- but I'm not sure it is a good idea. pgx supports handling NULL
via scanning a pointer to pointer. It also supports NULL via a sql.Scanner
. But not both at the same time. It seems to be something that only ever worked by accident.
And it definitely is not supported in pgx v5. The pointer to pointer NULL
path takes precedence over the sql.Scanner
path.
fix lgfm, thank you!
👍
Updating from v1.8.1 to v1.12.0 fails our tests with panic when scanning null enum value from pg.
After some research, it seems that this commit https://github.com/jackc/pgtype/commit/824d8ad40daa6ab015603df0dba250769d6c0653 and issue https://github.com/jackc/pgx/issues/1211 introducing the problem:
And its curious why do we need line with reflect.Set of zero value, when type implements sql.Scanner and should decide scanning behavior itself. https://github.com/jackc/pgtype/blob/master/pgtype.go#L621
Minimal test that shows problem:
Right now I dont have ideas how to fix that problem. Any suggestions?