(tables schema.Tables)
| 45 | } |
| 46 | |
| 47 | func (g *Generator) jsonifyTables(tables schema.Tables) []jsonTable { |
| 48 | jsonTables := make([]jsonTable, len(tables)) |
| 49 | for i, table := range tables { |
| 50 | jsonColumns := make([]jsonColumn, len(table.Columns)) |
| 51 | for c, col := range table.Columns { |
| 52 | jsonColumns[c] = jsonColumn{ |
| 53 | Name: col.Name, |
| 54 | Type: col.Type.String(), |
| 55 | TypeSchema: col.TypeSchema, |
| 56 | // Technically this would enable the UI to continue to show the underlying PK columns |
| 57 | // This is a short term hack |
| 58 | IsPrimaryKey: (col.PrimaryKey && !(col.Name == schema.CqIDColumn.Name && len(table.PrimaryKeyComponents()) > 0)) || col.PrimaryKeyComponent, |
| 59 | IsPrimaryKeyComponent: col.PrimaryKeyComponent, |
| 60 | IsIncrementalKey: col.IncrementalKey, |
| 61 | } |
| 62 | } |
| 63 | jsonTables[i] = jsonTable{ |
| 64 | Name: table.Name, |
| 65 | Title: table.Title, |
| 66 | Description: table.Description, |
| 67 | Columns: jsonColumns, |
| 68 | IsPaid: table.IsPaid, |
| 69 | IsIncremental: table.IsIncremental, |
| 70 | Relations: g.jsonifyTables(table.Relations), |
| 71 | PermissionsNeeded: table.PermissionsNeeded, |
| 72 | SensitiveColumns: table.SensitiveColumns, |
| 73 | } |
| 74 | } |
| 75 | return jsonTables |
| 76 | } |
no test coverage detected