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

如何查看gorm具体执行的sql语句 #1544

Closed
rfyiamcool opened this issue Jul 24, 2017 · 3 comments
Closed

如何查看gorm具体执行的sql语句 #1544

rfyiamcool opened this issue Jul 24, 2017 · 3 comments

Comments

@rfyiamcool
Copy link

gorm有现成的函数方法 可以方便的查看orm对应的sql语句么?

	db.Model(&MainTask{}).Where("task_id in ?", task_ids).Update(MainTask{TaskStatus: task_status, UpdatedAt: time.Now()})
@rfyiamcool rfyiamcool changed the title 如何查看gorm的sql语句 如何查看gorm具体执行的sql语句 Jul 24, 2017
@dinglixiang
Copy link

dinglixiang commented Jul 26, 2017

Try the Debug.

// Debug a single operation, show detailed log for this operation
db.Debug().Where("name = ?", "jinzhu").First(&User{})

Logger Doc

@rfyiamcool
Copy link
Author

@dinglixiang yes, thank U.

@liushooter
Copy link

db.LogMode(true)

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

3 participants