Gorm: mysql per-transaction isolation level

Created on 30 Mar 2017  路  2Comments  路  Source: go-gorm/gorm

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

Most helpful comment

Then, I am wondering if this feature is implemented. hmm

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kumarsiva07 picture kumarsiva07  路  3Comments

koalacxr picture koalacxr  路  3Comments

satb picture satb  路  3Comments

Ganitzsh picture Ganitzsh  路  3Comments

izouxv picture izouxv  路  3Comments