Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Unclear when default transaction is committed #737

Open
SRNissen opened this issue Feb 6, 2024 · 0 comments
Open

[Question] Unclear when default transaction is committed #737

SRNissen opened this issue Feb 6, 2024 · 0 comments
Assignees

Comments

@SRNissen
Copy link

SRNissen commented Feb 6, 2024

Document Link

https://gorm.io/docs/transactions.html

GORM perform write (create/update/delete) operations run inside a transaction to ensure data consistency, you can disable it during initialization if it is not required

Your Question

Assuming I do not disable the default transaction, when does the commit happen?

E.g.:

func main() {
    db, err := gorm.Open(sqlserver.Open("connectionString"), &gorm.Config{})
    if err != nil { panic("!") }
    u := User{}
    db.Create(&u)
    ?
}

Does this change get commited? If so - when?

Do I need to call .Commit() manually? If so - when?

Expected answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants