uptrace / bun

SQL-first Golang ORM

Home Page:https://bun.uptrace.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot get ID after inserting data

titans-fangyu opened this issue · comments

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
}

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