MakeColumns generates an array that has Gohan style column names
(s *schema.Schema, tableName string, fields []string, join bool)
| 763 | |
| 764 | // MakeColumns generates an array that has Gohan style column names |
| 765 | func MakeColumns(s *schema.Schema, tableName string, fields []string, join bool) []string { |
| 766 | manager := schema.GetManager() |
| 767 | |
| 768 | var include map[string]bool |
| 769 | if fields != nil { |
| 770 | include = make(map[string]bool) |
| 771 | for _, f := range fields { |
| 772 | include[f] = true |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | var cols []string |
| 777 | for _, property := range s.Properties { |
| 778 | if property.RelationProperty != "" && join { |
| 779 | relatedSchema, ok := manager.Schema(property.Relation) |
| 780 | if !ok { |
| 781 | panic(fmt.Sprintf("missing schema %s", property.Relation)) |
| 782 | } |
| 783 | aliasTableName := makeAliasTableName(tableName, property) |
| 784 | cols = append(cols, MakeColumns(relatedSchema, aliasTableName, fields, true)...) |
| 785 | } |
| 786 | |
| 787 | if include != nil && !include[normField(property.ID, s.ID)] { |
| 788 | continue |
| 789 | } |
| 790 | |
| 791 | cols = append(cols, makeColumn(tableName, property)+" as "+quote(makeColumnID(tableName, property))) |
| 792 | } |
| 793 | return cols |
| 794 | } |
| 795 | |
| 796 | func makeStateColumns(s *schema.Schema) (cols []string) { |
| 797 | dbTableName := s.GetDbTableName() |
no test coverage detected