You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I am writing some kind of a wrapper on top of Rows.Scan().
In some cases I need to scan into destination with type *interface{}. For example to fill map[string]interface{} or to skip current column value and don't scan it at all.
The call can look like that:
varsstringvariinterface{}
err:=rows.Scan(&s, &i)
Of course I am simplifying it, and in the real case I would use the reflection.
Nonetheless, currently pgx.Rows can't scan into destination with type *interface{}. I checked how sql.Rows behaves in this situation (with pgx as a driver), and it scan into *interface{} perfectly. I think it's worth implementing it in pgx.Rows too, for consistency.
If I am wrong and this was your intentional restriction, how can I implement what I need?
I can get all row values via Rows.Values() and for *inteface{} destinations assign corresponding row value from the list, but I still need to call pgx.Scan() for non *interface{} destinations and I need some kind of placeholder in place of *interface{} destinations.
Looking at the example above after I assign i from Rows.Values() I need to put something instead of &i to rows.Scan() call in order it to succeed. What would be the most efficient and elegant way to do that?
The text was updated successfully, but these errors were encountered:
Hi. I am writing some kind of a wrapper on top of
Rows.Scan()
.In some cases I need to scan into destination with type
*interface{}
. For example to fillmap[string]interface{}
or to skip current column value and don't scan it at all.The call can look like that:
Of course I am simplifying it, and in the real case I would use the reflection.
Nonetheless, currently
pgx.Rows
can't scan into destination with type*interface{}
. I checked howsql.Rows
behaves in this situation (withpgx
as a driver), and it scan into*interface{}
perfectly. I think it's worth implementing it inpgx.Rows
too, for consistency.If I am wrong and this was your intentional restriction, how can I implement what I need?
I can get all row values via
Rows.Values()
and for*inteface{}
destinations assign corresponding row value from the list, but I still need to callpgx.Scan()
for non*interface{}
destinations and I need some kind of placeholder in place of*interface{}
destinations.Looking at the example above after I assign
i
fromRows.Values()
I need to put something instead of&i
torows.Scan()
call in order it to succeed. What would be the most efficient and elegant way to do that?The text was updated successfully, but these errors were encountered: