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 }
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 }