// Insert insert a migration entry into database
163675
func (m *GenericDriver) Insert(e MigrationRecord) error {

	err := transaction(m.DB, func(tx *sql.Tx) error {
		_, err := tx.Exec(m.Dialect.InsertSQL(),
			e.Version,
			e.Description,
			e.Checksum,
			e.AppliedAt.Unix(),
			e.ExecutionTime,
		)
		return err
	})

	return err
}
624260
func (dct *DjangoContentType) Insert(db XODB) error {
	var err error

	// if already exist, bail
	if dct._exists {
		return errors.New("insert failed: already exists")
	}

	// sql insert query, primary key provided by sequence
	const sqlstr = `INSERT INTO public.django_content_type (` +
		`app_label, model` +
		`) VALUES (` +
		`$1, $2` +
		`) RETURNING id`

	// run query
	XOLog(sqlstr, dct.AppLabel, dct.Model)
	err = db.QueryRow(sqlstr, dct.AppLabel, dct.Model).Scan(&dct.ID)
	if err != nil {
		return err
	}

	// set existence
	dct._exists = true

	return nil
}
801843
func (entries *Entries) insert(entry Entry) Entry {
	i := entries.search(entry.Key())

	if i == len(*entries) {
		*entries = append(*entries, entry)
		return nil
	}

	if (*entries)[i].Key() == entry.Key() {
		oldEntry := (*entries)[i]
		(*entries)[i] = entry
		return oldEntry
	}

	(*entries) = append(*entries, nil)
	copy((*entries)[i+1:], (*entries)[i:])
	(*entries)[i] = entry
	return nil
}
287468
func (me *Dataset) Insert(i ...interface{}) *CrudExec {
	sql, args, err := me.ToInsertSql(i...)
	return newCrudExec(me.database, err, sql, args...)
}
1128593
func (s *ChocolateStorage) Insert(c model.Chocolate) string {
	id := fmt.Sprintf("%d", s.idCount)
	c.ID = id
	s.chocolates[id] = &c
	s.idCount++
	return id
}
263086
func (rev *Revocation) Insert(tx *sql.Tx) error {
	_, err := tx.Exec(`INSERT INTO revocations (ski, revoked_at, mechanism, reason) VALUES (?, ?, ?, ?)`, rev.SKI, rev.RevokedAt, rev.Mechanism, rev.Reason)
	return err
}
588830
func (ag *AuthGroup) Insert(db XODB) error {
	var err error

	// if already exist, bail
	if ag._exists {
		return errors.New("insert failed: already exists")
	}

	// sql query
	const sqlstr = `INSERT INTO django.auth_group (` +
		`name` +
		`) VALUES (` +
		`:1` +
		`) RETURNING id /*lastInsertId*/ INTO :pk`

	// run query
	XOLog(sqlstr, ag.Name, nil)
	res, err := db.Exec(sqlstr, ag.Name, nil)
	if err != nil {
		return err
	}

	// retrieve id
	id, err := res.LastInsertId()
	if err != nil {
		return err
	}

	// set primary key and existence
	ag.ID = float64(id)
	ag._exists = true

	return nil
}
878200
func Insert(newTopic *db.AvailableTopic) string {
	return db.Conn.Insert(db.AvailableTopicCollection, newTopic)
}
504560
func (a Account) Insert() (int, error) {
	accountMaxID++
	a.ID = accountMaxID
	a.Name = fmt.Sprintf("account_%d", accountMaxID)
	accounts = append(accounts, a)
	return accountMaxID, nil
}
385478
func Insert(table string) *InsertBuilder {
	return &InsertBuilder{
		tableName: table,
		query:     fmt.Sprintln(`INSERT INTO`, table),
		lock:      new(sync.Mutex),
	}
}
1370038
func (t *Tree) Insert(k []byte, v interface{}) (*Tree, interface{}, bool) {
	txn := t.Txn()
	old, ok := txn.Insert(k, v)
	return txn.Commit(), old, ok
}
906377
func (db *Storage) Insert(ctxt Context, val interface{}) error {
	ctxt = debugContext(ctxt)
	t, _, err := db.findType(val, "Insert")
	if err != nil {
		return err
	}

	var args []interface{}
	rval := reflect.ValueOf(val).Elem()
	var rowcol *field
	for _, col := range t.fields {
		rv := rval.FieldByIndex(col.index)
		if col.rowid && rv.Int() == 0 {
			rowcol = col
			args = append(args, nil)
		} else {
			args = append(args, rval.FieldByIndex(col.index).Interface())
		}
	}

	var buf bytes.Buffer
	if t.fts4 {
		fmt.Fprintf(&buf, "update %q", t.name)
		fmt.Fprintf(&buf, " set ")
		sep := ""
		var args1 []interface{}
		for i, col := range t.fields {
			if !col.key {
				fmt.Fprintf(&buf, "%s%q = ?", sep, col.name)
				sep = ", "
				args1 = append(args1, args[i])
			}
		}
		fmt.Fprintf(&buf, " where ")
		sep = ""
		for i, col := range t.fields {
			if col.key {
				fmt.Fprintf(&buf, "%s%q = ?", sep, col.name)
				sep = ", "
				args1 = append(args1, args[i])
			}
		}

		res, err := ctxt.Exec(buf.String(), args1...)
		if err != nil {
			return err
		}
		count, err := res.RowsAffected()
		if err != nil {
			return err
		}
		if count > 0 {
			return nil
		}
		// fall through to ordinary insert command
		buf.Reset()
	}

	fmt.Fprintf(&buf, "insert or replace into %q (", t.name)
	for i, col := range t.fields {
		if i > 0 {
			fmt.Fprintf(&buf, ", ")
		}
		fmt.Fprintf(&buf, "%q", col.name)
	}
	fmt.Fprintf(&buf, ") values (")
	for i := range t.fields {
		if i > 0 {
			fmt.Fprintf(&buf, ", ")
		}
		fmt.Fprintf(&buf, "?")
	}
	fmt.Fprintf(&buf, ")")

	res, err := ctxt.Exec(buf.String(), args...)
	if err != nil {
		return err
	}
	if rowcol != nil {
		id, err := res.LastInsertId()
		if err != nil {
			return err
		}
		rval.FieldByIndex(rowcol.index).SetInt(id)
	}
	return nil
}
917322
func Insert(eq ...interface{}) *Builder {
	builder := &Builder{cond: NewCond()}
	return builder.Insert(eq...)
}
1301639
func (session *Session) Insert(beans ...interface{}) (int64, error) {
	var affected int64
	var err error

	if session.IsAutoClose {
		defer session.Close()
	}

	for _, bean := range beans {
		sliceValue := reflect.Indirect(reflect.ValueOf(bean))
		if sliceValue.Kind() == reflect.Slice {
			size := sliceValue.Len()
			if size > 0 {
				if session.Engine.SupportInsertMany() {
					cnt, err := session.innerInsertMulti(bean)
					session.resetStatement()
					if err != nil {
						return affected, err
					}
					affected += cnt
				} else {
					for i := 0; i < size; i++ {
						cnt, err := session.innerInsert(sliceValue.Index(i).Interface())
						session.resetStatement()
						if err != nil {
							return affected, err
						}
						affected += cnt
					}
				}
			}
		} else {
			cnt, err := session.innerInsert(bean)
			session.resetStatement()
			if err != nil {
				return affected, err
			}
			affected += cnt
		}
	}

	return affected, err
}
970993
func (h *sqlHelper) Insert(
	logger lager.Logger,
	q Queryable,
	table string,
	attributes SQLAttributes,
) (sql.Result, error) {
	attributeCount := len(attributes)
	if attributeCount == 0 {
		return nil, nil
	}

	query := fmt.Sprintf("INSERT INTO %s\n", table)
	attributeNames := make([]string, 0, attributeCount)
	attributeBindings := make([]string, 0, attributeCount)
	bindings := make([]interface{}, 0, attributeCount)

	for column, value := range attributes {
		attributeNames = append(attributeNames, column)
		attributeBindings = append(attributeBindings, "?")
		bindings = append(bindings, value)
	}
	query += fmt.Sprintf("(%s)", strings.Join(attributeNames, ", "))
	query += fmt.Sprintf("VALUES (%s)", strings.Join(attributeBindings, ", "))

	return q.Exec(h.Rebind(query), bindings...)
}
1026396
func (tr *TimeRange) Insert(t time.Time) {
	tr.InsertMax(t)
	tr.InsertMin(t)
}
186817
func (b *Bulk) Insert(docs ...interface{}) {
	action := b.action(bulkInsert)
	action.docs = append(action.docs, docs...)
}