Hi,
I am using postgresql, when run the below
`
type person struct {
FirstName string
LastName string
Gender string
}
persons := []person{
{
"f1",
"l1",
"m",
},
{
"f2",
"l2",
"m",
},
}
`
insertCmd := INSERT INTO person(first_name, last_name, gender)
VALUES(:firstname, :lastname, :gender)
db.NamedExec(insertCmd, persons )
getting errors:
panic: reflect: call of github.com/jmoiron/sql/reflectx.(*Mapper).TraversalsByNameFunc on slice Value,
I found tests https://github.com/jmoiron/sqlx/blob/master/named_test.go#L194 works,
any advice?
check if you are using the master brach.
I'm using go dep -> dep ensure, use the master branch but in the vendor not the latest version of code...
hi will there be a new release soon to include the bug fixes?
Code below would not work.
persons := []map[string]interface{}{
{
"first": "Bin",
"last": "Smuth",
"email": "[email protected]",
},
{
"first": "Bin2",
"last": "Smuth2",
"email": "[email protected]",
},
}
_, err = db.NamedExec(`INSERT INTO person (first_name,last_name,email) VALUES (:first,:last,:email)`, persons)
print(err)
I noticed go get -u does not download the latest version (1.2.1) but an older one (1.2.0) if no entry in go.mod exists. That older version does not, for instance, support NamedExec with slices.
I have to change the version manually to v1.2.1-0.20200324155115-ee514944af4b.
Most helpful comment
check if you are using the master brach.