lxd/db/query/config.go
func upsertConfig(tx *sql.Tx, table string, values map[string]string) error {
	if len(values) == 0 {
		return nil // Nothing to update
	}

	query := fmt.Sprintf("INSERT OR REPLACE INTO %s (key, value) VALUES", table)
	exprs := []string{}
	params := []interface{}{}
	for key, value := range values {
		exprs = append(exprs, "(?, ?)")
		params = append(params, key)
		params = append(params, value)
	}
	query += strings.Join(exprs, ",")
	_, err := tx.Exec(query, params...)
	return err
}
func upsertConfig(tx *sql.Tx, table string, values map[string]string) error {
	if len(values) == 0 {
		return nil // Nothing to update
	}

	query := fmt.Sprintf("INSERT OR REPLACE INTO %s (key, value) VALUES", table)
	exprs := []string{}
	params := []interface{}{}
	for key, value := range values {
		exprs = append(exprs, "(?, ?)")
		params = append(params, key)
		params = append(params, value)
	}
	query += strings.Join(exprs, ",")
	_, err := tx.Exec(query, params...)
	return err
}
func upsertConfig ( tx * sql . Tx , table string , values map [ string ] string ) error { if len ( values ) == 0 { return nil // Nothing to update } query := fmt . Sprintf ( " " , table ) exprs := [ ] string { } params := [ ] interface { } { } for key , value := range values { exprs = append ( exprs , " " ) params = append ( params , key ) params = append ( params , value ) } query += strings . Join ( exprs , " " ) _ , err := tx . Exec ( query , params ... ) return err }
// Insert or updates the key/value rows of the given config table.
Insert or updates the key / value rows of the given config table .