Closed
Description
When using the pgx
driver the following query where ids
is a Postgres array integer[]
fails with the error: sql: Scan error on column index 0: unsupported driver -> Scan pair: string -> *[]int32
conn, err = sqlx.Connect("pgx", ...)
if err != nil {
log.Fatal(err)
}
query := fmt.Sprintf(`
SELECT
ids
FROM
%v
WHERE
id=1
`, IdsTable)
var ids []int32
err = conn.QueryRow(query).Scan(&ids)
If I use the pgx
driver directly, the array is decoded into a Go slice fine. Here's the code:
conn, err := pgx.Connect(config)
if err != nil {
log.Fatal(err)
}
query := fmt.Sprintf(`
SELECT
ids
FROM
%v
WHERE
id=1
`, IdsTable)
var ids []int32
err = conn.QueryRow(query).Scan(&ids)
Any idea why using sqlx
is interpreting the Postgres array integer[]
as a string?
Metadata
Metadata
Assignees
Labels
No labels