Closed robfordww closed 2 years ago
Hello! This is indeed a limitation in the current scany implementation. See this comment for more details: https://github.com/georgysavva/scany/issues/33#issuecomment-813221294 I have plans to fix it in the future, but for now, a workaround to scan using scany would be:
type Row struct {
T time.Time
}
row := &Row{}
if err := pgxscan.Get(ctx, pgxConn, row, "select now() as t"); err != nil {
return nil, err
}
fmt.Println(row.T)
I have noticed that the
.Get()
method of Scany and Sqlx varies when you try to scan aselect now()
into avar t time.Time
.Scany.Get()
treats the&t
as a struct with missing fields, whilesqlx.Get()
does write the value into the variable. Is this "by design"? I noticed this when switching from Sqlx to Scany.