MCPcopy Create free account
hub / github.com/cloudwan/gohan / makeJoin

Function makeJoin

db/sql/sql.go:806–820  ·  view source on GitHub ↗
(s *schema.Schema, tableName string, q sq.SelectBuilder)

Source from the content-addressed store, hash-verified

804}
805
806func makeJoin(s *schema.Schema, tableName string, q sq.SelectBuilder) sq.SelectBuilder {
807 manager := schema.GetManager()
808 for _, property := range s.Properties {
809 if property.RelationProperty == "" {
810 continue
811 }
812 relatedSchema, _ := manager.Schema(property.Relation)
813 aliasTableName := makeAliasTableName(tableName, property)
814 q = q.LeftJoin(
815 fmt.Sprintf("%s as %s on %s.%s = %s.id", quote(relatedSchema.GetDbTableName()), quote(aliasTableName),
816 quote(tableName), quote(property.ID), quote(aliasTableName)))
817 q = makeJoin(relatedSchema, aliasTableName, q)
818 }
819 return q
820}
821
822func decodeState(data map[string]interface{}, state *transaction.ResourceState) error {
823 var ok bool

Callers 1

buildSelectFunction · 0.85

Calls 4

makeAliasTableNameFunction · 0.85
GetDbTableNameMethod · 0.80
quoteFunction · 0.70
SchemaMethod · 0.65

Tested by

no test coverage detected