go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly
https://gorm.io
MIT License
36.48k stars 3.9k forks source link

Create In Batches within transaction fails while using prepared statements #6006

Open theStuRat opened 1 year ago

theStuRat commented 1 year ago

GORM Playground Link

https://github.com/go-gorm/playground/pull/560

Description

We would like to be able to execute a single transaction which creates a large number of table rows and then queries all the contents of that table to be returned. To do this we are using CreateInBatches within a Transaction call.

The issue occurs because we have PreparedStatement in the config set to true and the underlying driver, mysql in our case, does not allow for preparing SAVEPOINT statements

mwagner-p commented 1 year ago

Would love to see this getting implemented, as well!