Open Kangaroux opened 5 months ago
The conditions for this to happen are a little strange:
db.Select()
bytea
sql.RawBytes
$1
postgres=# create table foo (data bytea); CREATE TABLE postgress=# insert into foo values ('\xdead'), ('\xbeef'), ('\xdeadbeef'); INSERT 0 3 postgres=# select * from foo; data -------- \xdead \xbeef \xdeadbeef (3 rows)
db := sqlx.MustConnect("postgres", ...) var result [][]byte db.Select(&result, `select * from foo where $1=1`, 1) fmt.Printf("%x %x %x\n", result[0], result[1], result[2]) var result2 []sql.RawBytes db.Select(&result2, `select * from foo where $1=1`, 1) fmt.Printf("%x %x %x\n", result2[0], result2[1], result2[2]) /* dead beef deadbeef 2033 2033 203300ef */
I didn't notice this problem with Query or Queryx.
Query
Queryx
postgres:16-alpine
lib/pq
sqlx
The conditions for this to happen are a little strange:
db.Select()
must be usedbytea
sql.RawBytes
(or a struct field that issql.RawBytes
)$1
I didn't notice this problem with
Query
orQueryx
.postgres:16-alpine
docker image)lib/pq
v1.10.9sqlx
v1.4.0