You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// LeftJoinOnField performs as LeftJoin, but it joins both tables with the same field name.
//
// Eg:
// Model("order").LeftJoinOnField("user", "user_id")
// Model("order").LeftJoinOnField("product", "product_id").
func (m *Model) LeftJoinOnField(table, field string) *Model {
return m.doJoin("LEFT", table, fmt.Sprintf(
`%s.%s=%s.%s`,
m.tablesInit,
m.db.GetCore().QuoteWord(field),
m.db.GetCore().QuoteWord(table),
m.db.GetCore().QuoteWord(field),
))
}
Hello @kg1990. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
你好 @kg1990。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。
目前框架里面的JoinOnField的函数只支持相同列名的join,这个在实际的数据库设计场景里面所覆盖度不是很广
例如:
A表主键id字段,B表依赖于A表的id字段,设置字段名为a_id,在下面的示例里面,例如user,一般不会设置一个user_id的字段作为自己的主键
虽然有直接的leftjoin的方法支持,但是是属于硬编码支持,推荐在里面支持一下源字段和连接的目标字段,这样应该更加通用一点
The text was updated successfully, but these errors were encountered: