astaxie/beego — pull request #486 by kylemcc (2014-01-28 00:06:49+00:00)
Title: [orm] Add a Debug method to allow for debugging individual queries.

Hi! I have another addition for you to consider. I was looking for an easy to be able to debug individual queries without turning debug on globally. Let me know if there's a better way to accomplish this. Here's what I've come up with:

o := NewOrm()
u := &User{Name: "Kyle"}
o.Read(user, "Name") // logs nothing

u2 := &User{Email: "kylemcc@gmail.com"}
o.Debug().Read(u2, "Email") // logs debug query: SELECT `id`, `name`, `email` FROM `user` WHERE `email` = "kylemcc@gmail.com";

qs := o.Debug().QueryTable("users")
qs.Filter("Profile__Id", 10).One(u) // also logs debug query