Exemplo n.º 1
0
func getOnDuplicateUpdateColumns(assignList []*expression.Assignment, t table.Table) (map[int]*expression.Assignment, error) {
	m := make(map[int]*expression.Assignment, len(assignList))

	for _, v := range assignList {
		c, err := findColumnByName(t, field.JoinQualifiedName("", v.TableName, v.ColName))
		if err != nil {
			return nil, errors.Trace(err)
		}
		m[c.Offset] = v
	}
	return m, nil
}
Exemplo n.º 2
0
func (s *SelectList) updateFields(table string, resultFields []*field.ResultField) {
	// TODO: check database name later.
	for _, v := range resultFields {
		if table == "" || table == v.TableName {
			name := field.JoinQualifiedName("", v.TableName, v.Name)

			f := &field.Field{
				Expr: &expression.Ident{
					CIStr: model.NewCIStr(name),
				},
			}

			s.AddField(f, v.Clone())
		}
	}
}