query_set_components_update_table.go
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package domain
func (qc *QueryComponent) UpdateTables(tables ...*Table) {
for _, table := range tables {
qc.updateTable(table)
}
}
func (qc *QueryComponent) updateTable(table *Table) {
for i := range qc.Conditions {
qc.Conditions[i].FieldLeft.UpdateTable(table)
qc.Conditions[i].FieldRight.UpdateTable(table)
}
for i := range qc.Selects {
qc.Selects[i].FieldLeft.UpdateTable(table)
qc.Selects[i].FieldRight.UpdateTable(table)
for j := range qc.Selects[i].SubSelects {
qc.Selects[i].SubSelects[j].FieldLeft.UpdateTable(table)
qc.Selects[i].SubSelects[j].FieldRight.UpdateTable(table)
}
}
if qc.Formula != nil && len(qc.Formula.ExprHuman) > 0 {
qc.Formula.FieldExpr.UpdateTable(table)
}
if qc.Aggregation != nil {
for i := range qc.Aggregation.RowFields {
qc.Aggregation.RowFields[i].Expr.UpdateTable(table)
}
for i := range qc.Aggregation.ValueFields {
qc.Aggregation.ValueFields[i].Expr.UpdateTable(table)
}
}
if qc.Layout != nil {
for i := range qc.Layout.Cells {
if qc.Layout.Cells[i].Data == nil || qc.Layout.Cells[i].Data.TableField == nil {
continue
}
if qc.Layout.Cells[i].Data.TableField.TableId == table.TableId {
qc.Layout.Cells[i].Data.TableField.TableName = table.Name
}
}
}
}