uptrace / bun

SQL-first Golang ORM
https://bun.uptrace.dev
BSD 2-Clause "Simplified" License
3.65k stars 221 forks source link

Cannot get ID after inserting data #925

Open titans-fangyu opened 11 months ago

titans-fangyu commented 11 months ago

When I upgrade github.com/uptrace/bun from v1.0.19 to v1.1.14, the following code no longer works and cannot get the Id after inserting data. this is bug ???

books := []Book{book1, book2} res, err := db.NewInsert().Model(&books).Exec(ctx) if err != nil { panic(err) }

for _, book := range books { fmt.Println(book.ID) // book id is scanned automatically }

titans-fangyu commented 11 months ago

Id intbun:"id,pk,autoincrement"`` The new version needs to be tagged...