本文整理匯總了Golang中github.com/lann/squirrel.SelectBuilder.LeftJoin方法的典型用法代碼示例。如果您正苦於以下問題:Golang SelectBuilder.LeftJoin方法的具體用法?Golang SelectBuilder.LeftJoin怎麽用?Golang SelectBuilder.LeftJoin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lann/squirrel.SelectBuilder
的用法示例。
在下文中一共展示了SelectBuilder.LeftJoin方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: makeJoin
func makeJoin(s *schema.Schema, q sq.SelectBuilder) sq.SelectBuilder {
manager := schema.GetManager()
for _, property := range s.Properties {
if property.RelationProperty == "" {
continue
}
relatedSchema, _ := manager.Schema(property.Relation)
q = q.LeftJoin(
quote(relatedSchema.GetDbTableName()) + fmt.Sprintf(" on %s.%s = %s.id", s.GetDbTableName(), property.ID, relatedSchema.GetDbTableName()))
q = makeJoin(relatedSchema, q)
}
return q
}
示例2: makeJoin
func makeJoin(s *schema.Schema, tableName string, q sq.SelectBuilder) sq.SelectBuilder {
manager := schema.GetManager()
for _, property := range s.Properties {
if property.RelationProperty == "" {
continue
}
relatedSchema, _ := manager.Schema(property.Relation)
aliasTableName := makeAliasTableName(tableName, property)
q = q.LeftJoin(
fmt.Sprintf("%s as %s on %s.%s = %s.id", quote(relatedSchema.GetDbTableName()), quote(aliasTableName),
quote(tableName), quote(property.ID), quote(aliasTableName)))
q = makeJoin(relatedSchema, aliasTableName, q)
}
return q
}