When gorm transaction is created, it simply calls underlying Begin(). Unfortunately, it doesn't allow you to specify isolation level for the transaction.
In postgres you can call SET TRANSACTION ISOLATION LEVEL inside the transaction. It's somewhat ugly, because it's dialect-specific code, but it will work.
However, in mysql, there seems to be no way to change transaction isolation level at all. According to the documentation, you need to call SET TRANSACTION just before starting a transaction for it to have effect. Trying to call it inside a transaction causes an error.
I think the solution would be to use BeginTx() from the underlying DB, that allows specifying isolation level.
https://golang.org/pkg/database/sql/#DB.BeginTx
Thank you for your suggestion, I am thinking to integrate the Context into GORM already.
Thank you.
Then, I am wondering if this feature is implemented. hmm
Most helpful comment
Then, I am wondering if this feature is implemented. hmm