// updateColumns removes any columns that weren't matched by the fields.
503765
func (stmt *InsertStmt) updateColumns() {
	// TODO keep actual target columns separate from requested in case
	// the statement is updated?
	for _, column := range stmt.columns {
		if !stmt.fields.HasColumn(column.Name()) {
			// TODO pass an index to prevent further nesting of iteration
			stmt.columns = removeColumn(stmt.columns, column.Name())
		}
	}
}
953411
func (scope *Scope) SetColumn(column interface{}, value interface{}) error {
	var updateAttrs = map[string]interface{}{}
	if attrs, ok := scope.InstanceGet("gorm:update_attrs"); ok {
		updateAttrs = attrs.(map[string]interface{})
		defer scope.InstanceSet("gorm:update_attrs", updateAttrs)
	}

	if field, ok := column.(*Field); ok {
		updateAttrs[field.DBName] = value
		return field.Set(value)
	} else if name, ok := column.(string); ok {
		var (
			dbName           = ToDBName(name)
			mostMatchedField *Field
		)
		for _, field := range scope.Fields() {
			if field.DBName == value {
				updateAttrs[field.DBName] = value
				return field.Set(value)
			}
			if (field.DBName == dbName) || (field.Name == name && mostMatchedField == nil) {
				mostMatchedField = field
			}
		}

		if mostMatchedField != nil {
			updateAttrs[mostMatchedField.DBName] = value
			return mostMatchedField.Set(value)
		}
	}
	return errors.New("could not convert column to field")
}
760042
func (b *UpdateBuilder) Add(column string) *UpdateBuilder {
	return b.addValue(column, param(column))
}
252581
func (c *fischers) Update(fischer *v1alpha1.Fischer) (result *v1alpha1.Fischer, err error) {
	result = &v1alpha1.Fischer{}
	err = c.client.Put().
		Resource("fischers").
		Name(fischer.Name).
		Body(fischer).
		Do().
		Into(result)
	return
}
837669
func (me *DefaultAdapter) updateValuesSql(buf *SqlBuilder, updates ...UpdateExpression) error {
	if len(updates) == 0 {
		return NewGoquError("No update values provided")
	}
	updateLen := len(updates)
	for i, update := range updates {
		if err := me.Literal(buf, update); err != nil {
			return err
		}
		if i < updateLen-1 {
			buf.WriteRune(comma_rune)
		}
	}
	return nil

}
1306960
func (b *SqliteBuilder) RenameColumn(table, oldName, newName string) *Query {
	q := b.NewQuery("")
	q.LastError = errors.New("SQLite does not support renaming columns")
	return q
}
181688
func (o AnnotateOptions) updateAnnotations(obj runtime.Object) error {
	meta, err := api.ObjectMetaFor(obj)
	if err != nil {
		return err
	}
	if !o.overwrite {
		if err := validateNoAnnotationOverwrites(meta, o.newAnnotations); err != nil {
			return err
		}
	}

	if meta.Annotations == nil {
		meta.Annotations = make(map[string]string)
	}

	for key, value := range o.newAnnotations {
		meta.Annotations[key] = value
	}
	for _, annotation := range o.removeAnnotations {
		delete(meta.Annotations, annotation)
	}

	if len(o.resourceVersion) != 0 {
		meta.ResourceVersion = o.resourceVersion
	}
	return nil
}
884258
func SetColumnNames(list, set, hashMapOwner, keyValuePrefix string) {
	listCol = list
	setCol = set
	ownerCol = hashMapOwner
	kvPrefix = keyValuePrefix
}
378663
func (e *RegisteredEntity) ColumnNames(fieldNames []string) ([]string, error) {
	if fieldNames == nil || len(fieldNames) == 0 {
		for _, field := range e.table.ColToField {
			fieldNames = append(fieldNames, field)
		}
	}
	columnNames := make([]string, len(fieldNames))
	for i, fieldName := range fieldNames {
		columnName, ok := e.table.FieldToCol[fieldName]
		if !ok {
			return nil, errors.Errorf("%s is not a valid field for %s", fieldName, e.table.StructName)
		}
		columnNames[i] = columnName
	}
	return columnNames, nil
}
362563
func (c *Client) UpdateLogentries(i *UpdateLogentriesInput) (*Logentries, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Version == 0 {
		return nil, ErrMissingVersion
	}

	if i.Name == "" {
		return nil, ErrMissingName
	}

	path := fmt.Sprintf("/service/%s/version/%d/logging/logentries/%s", i.Service, i.Version, i.Name)
	resp, err := c.PutForm(path, i, nil)
	if err != nil {
		return nil, err
	}

	var l *Logentries
	if err := decodeJSON(&l, resp.Body); err != nil {
		return nil, err
	}
	return l, nil
}
785301
func (sc *StatementContext) UpdatedRows() uint64 {
	sc.mu.Lock()
	rows := sc.mu.updated
	sc.mu.Unlock()
	return rows
}
765272
func (db *postgres) ModifyColumnSql(tableName string, col *core.Column) string {
	return fmt.Sprintf("alter table %s ALTER COLUMN %s TYPE %s",
		tableName, col.Name, db.SqlType(col))
}
863919
func (table *Table) PKColumns() []*Column {
	columns := make([]*Column, len(table.PrimaryKeys))
	for i, name := range table.PrimaryKeys {
		columns[i] = table.GetColumn(name)
	}
	return columns
}
1110307
func (d *dbBase) setColsValues(mi *modelInfo, ind *reflect.Value, cols []string, values []interface{}, tz *time.Location) {
	for i, column := range cols {
		val := reflect.Indirect(reflect.ValueOf(values[i])).Interface()

		fi := mi.fields.GetByColumn(column)

		field := ind.Field(fi.fieldIndex)

		value, err := d.convertValueFromDB(fi, val, tz)
		if err != nil {
			panic(fmt.Errorf("Raw value: `%v` %s", val, err.Error()))
		}

		_, err = d.setFieldValue(fi, value, field)

		if err != nil {
			panic(fmt.Errorf("Raw value: `%v` %s", val, err.Error()))
		}
	}
}
7447
func (d *dbBase) Update(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time.Location, cols []string) (int64, error) {
	pkName, pkValue, ok := getExistPk(mi, ind)
	if ok == false {
		return 0, ErrMissPK
	}

	var setNames []string

	// if specify cols length is zero, then commit all columns.
	if len(cols) == 0 {
		cols = mi.fields.dbcols
		setNames = make([]string, 0, len(mi.fields.dbcols)-1)
	} else {
		setNames = make([]string, 0, len(cols))
	}

	setValues, err := d.collectValues(mi, ind, cols, true, false, &setNames, tz)
	if err != nil {
		return 0, err
	}

	setValues = append(setValues, pkValue)

	Q := d.ins.TableQuote()

	sep := fmt.Sprintf("%s = ?, %s", Q, Q)
	setColumns := strings.Join(setNames, sep)

	query := fmt.Sprintf("UPDATE %s%s%s SET %s%s%s = ? WHERE %s%s%s = ?", Q, mi.table, Q, Q, setColumns, Q, Q, pkName, Q)

	d.ins.ReplaceMarks(&query)

	res, err := q.Exec(query, setValues...)
	if err == nil {
		return res.RowsAffected()
	}
	return 0, err
}
468473
func SqTableColumns(db XODB, table string) ([]*SqColumn, error) {
	var err error

	// sql query
	var sqlstr = `PRAGMA table_info(` + table + `)`

	// run query
	XOLog(sqlstr)
	q, err := db.Query(sqlstr, table)
	if err != nil {
		return nil, err
	}
	defer q.Close()

	// load results
	res := []*SqColumn{}
	for q.Next() {
		sc := SqColumn{}

		// scan
		err = q.Scan(&sc.FieldOrdinal, &sc.ColumnName, &sc.DataType, &sc.NotNull, &sc.DefaultValue, &sc.PkColIndex)
		if err != nil {
			return nil, err
		}

		res = append(res, &sc)
	}

	return res, nil
}
1080724
func (r *boltRows) Columns() []string {
	fieldsInt, ok := r.metadata["fields"]
	if !ok {
		return []string{}
	}

	fields, ok := fieldsInt.([]interface{})
	if !ok {
		log.Errorf("Unrecognized fields from success message: %#v", fieldsInt)
		return []string{}
	}

	fieldsStr := make([]string, len(fields))
	for i, f := range fields {
		if fieldsStr[i], ok = f.(string); !ok {
			log.Errorf("Unrecognized fields from success message: %#v", fieldsInt)
			return []string{}
		}
	}
	return fieldsStr
}