// Insert inserts the AuthUserUserPermission to the database.
12028
func (auup *AuthUserUserPermission) Insert(db XODB) error {
	var err error

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

	// sql insert query, primary key provided by autoincrement
	const sqlstr = `INSERT INTO django.auth_user_user_permissions (` +
		`user_id, permission_id` +
		`) VALUES (` +
		`?, ?` +
		`)`

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

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

	// set primary key and existence
	auup.ID = int(id)
	auup._exists = true

	return nil
}
848755
func (dal *DjangoAdminLog) Insert(db XODB) error {
	var err error

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

	// sql query
	const sqlstr = `INSERT INTO django.django_admin_log (` +
		`action_time, object_id, object_repr, action_flag, change_message, content_type_id, user_id` +
		`) VALUES (` +
		`:1, :2, :3, :4, :5, :6, :7` +
		`) RETURNING id /*lastInsertId*/ INTO :pk`

	// run query
	XOLog(sqlstr, dal.ActionTime, dal.ObjectID, dal.ObjectRepr, dal.ActionFlag, dal.ChangeMessage, dal.ContentTypeID, dal.UserID, nil)
	res, err := db.Exec(sqlstr, dal.ActionTime, dal.ObjectID, dal.ObjectRepr, dal.ActionFlag, dal.ChangeMessage, dal.ContentTypeID, dal.UserID, nil)
	if err != nil {
		return err
	}

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

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

	return nil
}
417339
func (aia *AIA) Insert(tx *sql.Tx) error {
	_, err := tx.Exec(`INSERT INTO aia (ski, url) values (?, ?)`, aia.SKI, aia.URL)
	return err
}
856462
func (db *usersDB) Insert(email, fullname string) (schema.User, error) {
	defer db.mutex.Unlock()
	db.mutex.Lock()

	u := schema.User{
		Email:    email,
		Fullname: fullname,
	}
	db.users[email] = u
	return u, nil
}
1292664
func (adapter *Adapter) Insert(query grimoire.Query, changes map[string]interface{}, loggers ...grimoire.Logger) (interface{}, error) {
	statement, args := NewBuilder(adapter.Config).Insert(query.Collection, changes)
	id, _, err := adapter.Exec(statement, args, loggers...)
	return id, err
}
1320914
func (d *dbBase) Insert(q dbQuerier, mi *modelInfo, ind reflect.Value, tz *time.Location) (int64, error) {
	names := make([]string, 0, len(mi.fields.dbcols)-1)
	values, err := d.collectValues(mi, ind, mi.fields.dbcols, true, true, &names, tz)
	if err != nil {
		return 0, err
	}

	return d.InsertValue(q, mi, false, names, values)
}
1277662
func (dal *DjangoAdminLog) Insert(db XODB) error {
	var err error

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

	// sql insert query, primary key provided by sequence
	const sqlstr = `INSERT INTO public.django_admin_log (` +
		`action_time, object_id, object_repr, action_flag, change_message, content_type_id, user_id` +
		`) VALUES (` +
		`$1, $2, $3, $4, $5, $6, $7` +
		`) RETURNING id`

	// run query
	XOLog(sqlstr, dal.ActionTime, dal.ObjectID, dal.ObjectRepr, dal.ActionFlag, dal.ChangeMessage, dal.ContentTypeID, dal.UserID)
	err = db.QueryRow(sqlstr, dal.ActionTime, dal.ObjectID, dal.ObjectRepr, dal.ActionFlag, dal.ChangeMessage, dal.ContentTypeID, dal.UserID).Scan(&dal.ID)
	if err != nil {
		return err
	}

	// set existence
	dal._exists = true

	return nil
}
1026396
func (tr *TimeRange) Insert(t time.Time) {
	tr.InsertMax(t)
	tr.InsertMin(t)
}
792371
func (r *ChannelService) Insert(appId string, channelrequest *ChannelRequest) *ChannelInsertCall {
	c := &ChannelInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.appId = appId
	c.channelrequest = channelrequest
	return c
}
885187
func (d *Database) Insert(db DB, table string, src interface{}) error {
	pkName, pkValue, err := d.PrimaryKey(src)
	if err != nil {
		return err
	}
	if pkName != "" && pkValue != 0 {
		return fmt.Errorf("meddler.Insert: primary key must be zero")
	}

	// gather the query parts
	namesPart, err := d.ColumnsQuoted(src, false)
	if err != nil {
		return err
	}
	valuesPart, err := d.PlaceholdersString(src, false)
	if err != nil {
		return err
	}
	values, err := d.Values(src, false)
	if err != nil {
		return err
	}

	// run the query
	q := fmt.Sprintf("INSERT INTO %s (%s) VALUES (%s)", d.quoted(table), namesPart, valuesPart)
	if d.UseReturningToGetID && pkName != "" {
		q += " RETURNING " + d.quoted(pkName)
		var newPk int64
		err := db.QueryRow(q, values...).Scan(&newPk)
		if err != nil {
			return &dbErr{msg: "meddler.Insert: DB error in QueryRow", err: err}
		}
		if err = d.SetPrimaryKey(src, newPk); err != nil {
			return fmt.Errorf("meddler.Insert: Error saving updated pk: %v", err)
		}
	} else if pkName != "" {
		result, err := db.Exec(q, values...)
		if err != nil {
			return &dbErr{msg: "meddler.Insert: DB error in Exec", err: err}
		}

		// save the new primary key
		newPk, err := result.LastInsertId()
		if err != nil {
			return &dbErr{msg: "meddler.Insert: DB error getting new primary key value", err: err}
		}
		if err = d.SetPrimaryKey(src, newPk); err != nil {
			return fmt.Errorf("meddler.Insert: Error saving updated pk: %v", err)
		}
	} else {
		// no primary key, so no need to lookup new value
		_, err := db.Exec(q, values...)
		if err != nil {
			return &dbErr{msg: "meddler.Insert: DB error in Exec", err: err}
		}
	}

	return nil
}
259181
func (ap *AuthPermission) Upsert(db XODB) error {
	var err error

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

	// sql query
	const sqlstr = `INSERT INTO public.auth_permission (` +
		`id, name, content_type_id, codename` +
		`) VALUES (` +
		`$1, $2, $3, $4` +
		`) ON CONFLICT (id) DO UPDATE SET (` +
		`id, name, content_type_id, codename` +
		`) = (` +
		`EXCLUDED.id, EXCLUDED.name, EXCLUDED.content_type_id, EXCLUDED.codename` +
		`)`

	// run query
	XOLog(sqlstr, ap.ID, ap.Name, ap.ContentTypeID, ap.Codename)
	_, err = db.Exec(sqlstr, ap.ID, ap.Name, ap.ContentTypeID, ap.Codename)
	if err != nil {
		return err
	}

	// set existence
	ap._exists = true

	return nil
}
760673
func (agp *AuthGroupPermission) Save(db XODB) error {
	if agp.Exists() {
		return agp.Update(db)
	}

	return agp.Insert(db)
}
1215636
func (tm *transactionManager) insert(trans *transaction) {
	tm.Lock()
	defer tm.Unlock()

	tm.transactions.Set(trans.id, trans)
	tm.index.Set(tm.genIndexKeyByTrans(trans), trans)
}
1288578
func (journal *txJournal) insert(tx *types.Transaction) error {
	if journal.writer == nil {
		return errNoActiveJournal
	}
	if err := rlp.Encode(journal.writer, tx); err != nil {
		return err
	}
	return nil
}
665618
func (b *Bucket) Insert(key string, value interface{}, expiry uint32) (Cas, error) {
	cas, _, err := b.insert(key, value, expiry)
	return cas, err
}
1270738
func (s *Scope) Insert(obj *Object) (alt *Object) {
	if alt = s.Objects[obj.Name]; alt == nil {
		s.Objects[obj.Name] = obj
	}
	return
}
1208888
func (agp *AuthGroupPermission) Upsert(db XODB) error {
	var err error

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

	// sql query
	const sqlstr = `INSERT INTO public.auth_group_permissions (` +
		`id, group_id, permission_id` +
		`) VALUES (` +
		`$1, $2, $3` +
		`) ON CONFLICT (id) DO UPDATE SET (` +
		`id, group_id, permission_id` +
		`) = (` +
		`EXCLUDED.id, EXCLUDED.group_id, EXCLUDED.permission_id` +
		`)`

	// run query
	XOLog(sqlstr, agp.ID, agp.GroupID, agp.PermissionID)
	_, err = db.Exec(sqlstr, agp.ID, agp.GroupID, agp.PermissionID)
	if err != nil {
		return err
	}

	// set existence
	agp._exists = true

	return nil
}