improved docs
This commit is contained in:
parent
929df107f1
commit
66e697d3b1
|
@ -732,6 +732,8 @@ type User struct {
|
|||
|
||||
//assert(User.Userinfo.Id != 0 && User.Userdetail.Id != 0)
|
||||
|
||||
Please notice that Userinfo field on User should be before Userdetail because of the order on join SQL stsatement. If the order is wrong, the same name field may be set a wrong value.
|
||||
|
||||
Of course, If join statment is very long, you could directly use Sql():
|
||||
|
||||
err := engine.Sql("select * from userinfo, userdetail where userinfo.detail_id = userdetail.id").Find(&users)
|
||||
|
|
|
@ -853,6 +853,8 @@ money float64 `xorm:"Numeric"`
|
|||
var users = make([]User, 0)
|
||||
err := engine.Table(&Userinfo{}).Join("LEFT", "userdetail", "userinfo.detail_id = userdetail.id").Find(&users)
|
||||
|
||||
请注意这里的Userinfo在User中的位置必须在Userdetail的前面,因为他在join语句中的顺序在userdetail前面。如果顺序不对,那么对于同名的列,有可能会赋值出错。
|
||||
|
||||
当然,如果Join语句比较复杂,我们也可以直接用Sql函数
|
||||
|
||||
err := engine.Sql("select * from userinfo, userdetail where userinfo.detail_id = userdetail.id").Find(&users)
|
||||
|
|
Loading…
Reference in New Issue