Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: batch insert bind for ptr slice #805

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

fifsky
Copy link

@fifsky fifsky commented Apr 17, 2022

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

@dlsniper dlsniper added the needs testing The PR needs more testing before being accepted label Feb 1, 2024
@dlsniper
Copy link
Collaborator

dlsniper commented Feb 1, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs testing The PR needs more testing before being accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants