sqlx
sqlx copied to clipboard
fix: batch insert bind for ptr slice
Variables behave inconsistently when using batch inserts
people := []Person{}
db.Select(&people, "SELECT * FROM person ORDER BY first_name ASC") <---- this is ptr
// batch insert with structs
personStructs := []Person{
{FirstName: "Ardie", LastName: "Savea", Email: "[email protected]"},
{FirstName: "Sonny Bill", LastName: "Williams", Email: "[email protected]"},
{FirstName: "Ngani", LastName: "Laumape", Email: "[email protected]"},
}
_, err = db.NamedExec(`INSERT INTO person (first_name, last_name, email)
VALUES (:first_name, :last_name, :email)`, personStructs) <----- this not ptr
So, support batch insert used ptr slice
// batch insert with structs
personStructs := []Person{
{FirstName: "Ardie", LastName: "Savea", Email: "[email protected]"},
{FirstName: "Sonny Bill", LastName: "Williams", Email: "[email protected]"},
{FirstName: "Ngani", LastName: "Laumape", Email: "[email protected]"},
}
_, err = db.NamedExec(`INSERT INTO person (first_name, last_name, email)
VALUES (:first_name, :last_name, :email)`, &personStructs) <----- this ptr
Hello, @ardan-bkennedy, and I recently stepped in to help maintain this project. We are sorting the opened issues and pull requests and would like to know if you still NEED this merged. Thank you for your contribution.