Get a list of Column names to position
()
| 1476 | |
| 1477 | // Get a list of Column names to position |
| 1478 | func (m *SqlSource) ColumnPositions() map[string]int { |
| 1479 | if len(m.colIndex) > 0 { |
| 1480 | return m.colIndex |
| 1481 | } |
| 1482 | if m.Source == nil { |
| 1483 | return nil |
| 1484 | } |
| 1485 | cols := make(map[string]int) |
| 1486 | for idx, col := range m.Source.Columns { |
| 1487 | left, right, ok := col.LeftRight() |
| 1488 | //u.Debugf("aliasing: l:%v r:%v ok?%v", left, right, ok) |
| 1489 | if ok { |
| 1490 | cols[right] = idx |
| 1491 | } else { |
| 1492 | cols[left] = idx |
| 1493 | } |
| 1494 | } |
| 1495 | m.colIndex = cols |
| 1496 | return m.colIndex |
| 1497 | } |
| 1498 | |
| 1499 | // We need to be able to rewrite statements to convert a stmt such as: |
| 1500 | // |