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

Can Save() be executed in single transaction? #12

Closed
regorov opened this issue Nov 10, 2013 · 2 comments
Closed

Can Save() be executed in single transaction? #12

regorov opened this issue Nov 10, 2013 · 2 comments

Comments

@regorov
Copy link

regorov commented Nov 10, 2013

Example

type UserSetting {
Id int64
UserId int64
...
..
}

type User struct {
Id int64
Name string
Settings UserSetting
}

...
var
u User{Name: "Robert"} 
err := db.Save(&user)

command finished with error (problem was with table user_settings) but row was stayed in table users. Database has become unconsisted.

@jinzhu
Copy link
Member

jinzhu commented Nov 10, 2013

I understand, will implement transaction soon.

@jinzhu
Copy link
Member

jinzhu commented Nov 11, 2013

Added single transaction for Save, Update and Delete. So above code should works.

Also gorm got global transaction support. Check it out! https://github.com/jinzhu/gorm#transaction

@jinzhu jinzhu closed this as completed Nov 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants