• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang boil.Executor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/vattle/sqlboiler/boil.Executor的典型用法代码示例。如果您正苦于以下问题:Golang Executor类的具体用法?Golang Executor怎么用?Golang Executor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Executor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: SetStockcollections

// SetStockcollections removes all previously related items of the
// contact replacing them completely with the passed
// in related items, optionally inserting them as new records.
// Sets o.R.Contact's Stockcollections accordingly.
// Replaces o.R.Stockcollections with related.
// Sets related.R.Contact's Stockcollections accordingly.
func (o *Contact) SetStockcollections(exec boil.Executor, insert bool, related ...*Stockcollection) error {
	query := "update \"stockcollection\" set \"contact_id\" = null where \"contact_id\" = $1"
	values := []interface{}{o.ContactID}
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, query)
		fmt.Fprintln(boil.DebugWriter, values)
	}

	_, err := exec.Exec(query, values...)
	if err != nil {
		return errors.Wrap(err, "failed to remove relationships before set")
	}

	if o.R != nil {
		for _, rel := range o.R.Stockcollections {
			rel.ContactID.Valid = false
			if rel.R == nil {
				continue
			}

			rel.R.Contact = nil
		}

		o.R.Stockcollections = nil
	}
	return o.AddStockcollections(exec, insert, related...)
}
开发者ID:dictyBase,项目名称:Modware,代码行数:33,代码来源:contact.go


示例2: Delete

// Delete deletes a single StockRelationshipCvterm record with an executor.
// Delete will match against the primary key column to find the record to delete.
func (o *StockRelationshipCvterm) Delete(exec boil.Executor) error {
	if o == nil {
		return errors.New("chado: no StockRelationshipCvterm provided for delete")
	}

	if err := o.doBeforeDeleteHooks(exec); err != nil {
		return err
	}

	args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), stockRelationshipCvtermPrimaryKeyMapping)
	sql := "DELETE FROM \"stock_relationship_cvterm\" WHERE \"stock_relationship_cvterm_id\"=$1"

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, sql)
		fmt.Fprintln(boil.DebugWriter, args...)
	}

	_, err := exec.Exec(sql, args...)
	if err != nil {
		return errors.Wrap(err, "chado: unable to delete from stock_relationship_cvterm")
	}

	if err := o.doAfterDeleteHooks(exec); err != nil {
		return err
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:30,代码来源:stock_relationship_cvterm.go


示例3: Delete

// Delete deletes a single Download record with an executor.
// Delete will match against the primary key column to find the record to delete.
func (o *Download) Delete(exec boil.Executor) error {
	if o == nil {
		return errors.New("models: no Download provided for delete")
	}

	if err := o.doBeforeDeleteHooks(exec); err != nil {
		return err
	}

	args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), downloadPrimaryKeyMapping)
	sql := "DELETE FROM \"downloads\" WHERE \"id\"=$1"

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, sql)
		fmt.Fprintln(boil.DebugWriter, args...)
	}

	_, err := exec.Exec(sql, args...)
	if err != nil {
		return errors.Wrap(err, "models: unable to delete from downloads")
	}

	if err := o.doAfterDeleteHooks(exec); err != nil {
		return err
	}

	return nil
}
开发者ID:zqzca,项目名称:back,代码行数:30,代码来源:downloads.go


示例4: Delete

// Delete deletes a single AuthRolePermission record with an executor.
// Delete will match against the primary key column to find the record to delete.
func (o *AuthRolePermission) Delete(exec boil.Executor) error {
	if o == nil {
		return errors.New("chado: no AuthRolePermission provided for delete")
	}

	if err := o.doBeforeDeleteHooks(exec); err != nil {
		return err
	}

	args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), authRolePermissionPrimaryKeyMapping)
	sql := "DELETE FROM \"auth_role_permission\" WHERE \"auth_role_permission_id\"=$1"

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, sql)
		fmt.Fprintln(boil.DebugWriter, args...)
	}

	_, err := exec.Exec(sql, args...)
	if err != nil {
		return errors.Wrap(err, "chado: unable to delete from auth_role_permission")
	}

	if err := o.doAfterDeleteHooks(exec); err != nil {
		return err
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:30,代码来源:auth_role_permission.go


示例5: Delete

// Delete deletes a single FeaturepropPub record with an executor.
// Delete will match against the primary key column to find the record to delete.
func (o *FeaturepropPub) Delete(exec boil.Executor) error {
	if o == nil {
		return errors.New("chado: no FeaturepropPub provided for delete")
	}

	if err := o.doBeforeDeleteHooks(exec); err != nil {
		return err
	}

	args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), featurepropPubPrimaryKeyMapping)
	sql := "DELETE FROM \"featureprop_pub\" WHERE \"featureprop_pub_id\"=$1"

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, sql)
		fmt.Fprintln(boil.DebugWriter, args...)
	}

	_, err := exec.Exec(sql, args...)
	if err != nil {
		return errors.Wrap(err, "chado: unable to delete from featureprop_pub")
	}

	if err := o.doAfterDeleteHooks(exec); err != nil {
		return err
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:30,代码来源:featureprop_pub.go


示例6: SetDownloads

// SetDownloads removes all previously related items of the
// file replacing them completely with the passed
// in related items, optionally inserting them as new records.
// Sets o.R.File's Downloads accordingly.
// Replaces o.R.Downloads with related.
// Sets related.R.File's Downloads accordingly.
func (o *File) SetDownloads(exec boil.Executor, insert bool, related ...*Download) error {
	query := "update \"downloads\" set \"file_id\" = null where \"file_id\" = $1"
	values := []interface{}{o.ID}
	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, query)
		fmt.Fprintln(boil.DebugWriter, values)
	}

	_, err := exec.Exec(query, values...)
	if err != nil {
		return errors.Wrap(err, "failed to remove relationships before set")
	}

	if o.R != nil {
		for _, rel := range o.R.Downloads {
			rel.FileID.Valid = false
			if rel.R == nil {
				continue
			}

			rel.R.File = nil
		}

		o.R.Downloads = nil
	}
	return o.AddDownloads(exec, insert, related...)
}
开发者ID:zqzca,项目名称:back,代码行数:33,代码来源:files.go


示例7: Update

// Update uses an executor to update the AuthRolePermission.
// Whitelist behavior: If a whitelist is provided, only the columns given are updated.
// No whitelist behavior: Without a whitelist, columns are inferred by the following rules:
// - All columns are inferred to start with
// - All primary keys are subtracted from this set
// Update does not automatically update the record in case of default values. Use .Reload()
// to refresh the records.
func (o *AuthRolePermission) Update(exec boil.Executor, whitelist ...string) error {
	currTime := time.Now().In(boil.GetLocation())

	o.UpdatedAt.Time = currTime
	o.UpdatedAt.Valid = true

	var err error
	if err = o.doBeforeUpdateHooks(exec); err != nil {
		return err
	}
	key := makeCacheKey(whitelist, nil)
	authRolePermissionUpdateCacheMut.RLock()
	cache, cached := authRolePermissionUpdateCache[key]
	authRolePermissionUpdateCacheMut.RUnlock()

	if !cached {
		wl := strmangle.UpdateColumnSet(authRolePermissionColumns, authRolePermissionPrimaryKeyColumns, whitelist)
		if len(wl) == 0 {
			return errors.New("chado: unable to update auth_role_permission, could not build whitelist")
		}

		cache.query = fmt.Sprintf("UPDATE \"auth_role_permission\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, wl),
			strmangle.WhereClause("\"", "\"", len(wl)+1, authRolePermissionPrimaryKeyColumns),
		)
		cache.valueMapping, err = queries.BindMapping(authRolePermissionType, authRolePermissionMapping, append(wl, authRolePermissionPrimaryKeyColumns...))
		if err != nil {
			return err
		}
	}

	values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping)

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.query)
		fmt.Fprintln(boil.DebugWriter, values)
	}

	_, err = exec.Exec(cache.query, values...)
	if err != nil {
		return errors.Wrap(err, "chado: unable to update auth_role_permission row")
	}

	if !cached {
		authRolePermissionUpdateCacheMut.Lock()
		authRolePermissionUpdateCache[key] = cache
		authRolePermissionUpdateCacheMut.Unlock()
	}

	return o.doAfterUpdateHooks(exec)
}
开发者ID:dictyBase,项目名称:Modware,代码行数:58,代码来源:auth_role_permission.go


示例8: DeleteAll

// DeleteAll deletes all rows in the slice, using an executor.
func (o FeaturepropPubSlice) DeleteAll(exec boil.Executor) error {
	if o == nil {
		return errors.New("chado: no FeaturepropPub slice provided for delete all")
	}

	if len(o) == 0 {
		return nil
	}

	if len(featurepropPubBeforeDeleteHooks) != 0 {
		for _, obj := range o {
			if err := obj.doBeforeDeleteHooks(exec); err != nil {
				return err
			}
		}
	}

	var args []interface{}
	for _, obj := range o {
		pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), featurepropPubPrimaryKeyMapping)
		args = append(args, pkeyArgs...)
	}

	sql := fmt.Sprintf(
		"DELETE FROM \"featureprop_pub\" WHERE (%s) IN (%s)",
		strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, featurepropPubPrimaryKeyColumns), ","),
		strmangle.Placeholders(dialect.IndexPlaceholders, len(o)*len(featurepropPubPrimaryKeyColumns), 1, len(featurepropPubPrimaryKeyColumns)),
	)

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, sql)
		fmt.Fprintln(boil.DebugWriter, args)
	}

	_, err := exec.Exec(sql, args...)
	if err != nil {
		return errors.Wrap(err, "chado: unable to delete all from featurepropPub slice")
	}

	if len(featurepropPubAfterDeleteHooks) != 0 {
		for _, obj := range o {
			if err := obj.doAfterDeleteHooks(exec); err != nil {
				return err
			}
		}
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:featureprop_pub.go


示例9: SetCvterm

// SetCvterm of the cv to the related item.
// Sets o.R.Cvterm to related.
// Adds o to related.R.CV.
func (o *CV) SetCvterm(exec boil.Executor, insert bool, related *Cvterm) error {
	var err error

	if insert {
		related.CVID = o.CVID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"cvterm\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"cv_id"}),
			strmangle.WhereClause("\"", "\"", 2, cvtermPrimaryKeyColumns),
		)
		values := []interface{}{o.CVID, related.CvtermID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.CVID = o.CVID

	}

	if o.R == nil {
		o.R = &cvR{
			Cvterm: related,
		}
	} else {
		o.R.Cvterm = related
	}

	if related.R == nil {
		related.R = &cvtermR{
			CV: o,
		}
	} else {
		related.R.CV = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:cv.go


示例10: SetAuthRolePermission

// SetAuthRolePermission of the auth_permission to the related item.
// Sets o.R.AuthRolePermission to related.
// Adds o to related.R.AuthPermission.
func (o *AuthPermission) SetAuthRolePermission(exec boil.Executor, insert bool, related *AuthRolePermission) error {
	var err error

	if insert {
		related.AuthPermissionID = o.AuthPermissionID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"auth_role_permission\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"auth_permission_id"}),
			strmangle.WhereClause("\"", "\"", 2, authRolePermissionPrimaryKeyColumns),
		)
		values := []interface{}{o.AuthPermissionID, related.AuthRolePermissionID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.AuthPermissionID = o.AuthPermissionID

	}

	if o.R == nil {
		o.R = &authPermissionR{
			AuthRolePermission: related,
		}
	} else {
		o.R.AuthRolePermission = related
	}

	if related.R == nil {
		related.R = &authRolePermissionR{
			AuthPermission: o,
		}
	} else {
		related.R.AuthPermission = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:auth_permission.go


示例11: SetJbrowseTrack

// SetJbrowseTrack of the jbrowse_organism to the related item.
// Sets o.R.JbrowseTrack to related.
// Adds o to related.R.JbrowseOrganism.
func (o *JbrowseOrganism) SetJbrowseTrack(exec boil.Executor, insert bool, related *JbrowseTrack) error {
	var err error

	if insert {
		related.JbrowseOrganismID = o.JbrowseOrganismID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"jbrowse_track\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"jbrowse_organism_id"}),
			strmangle.WhereClause("\"", "\"", 2, jbrowseTrackPrimaryKeyColumns),
		)
		values := []interface{}{o.JbrowseOrganismID, related.JbrowseTrackID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.JbrowseOrganismID = o.JbrowseOrganismID

	}

	if o.R == nil {
		o.R = &jbrowseOrganismR{
			JbrowseTrack: related,
		}
	} else {
		o.R.JbrowseTrack = related
	}

	if related.R == nil {
		related.R = &jbrowseTrackR{
			JbrowseOrganism: o,
		}
	} else {
		related.R.JbrowseOrganism = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:jbrowse_organism.go


示例12: SetDbxref

// SetDbxref of the db to the related item.
// Sets o.R.Dbxref to related.
// Adds o to related.R.DB.
func (o *DB) SetDbxref(exec boil.Executor, insert bool, related *Dbxref) error {
	var err error

	if insert {
		related.DBID = o.DBID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"dbxref\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"db_id"}),
			strmangle.WhereClause("\"", "\"", 2, dbxrefPrimaryKeyColumns),
		)
		values := []interface{}{o.DBID, related.DbxrefID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.DBID = o.DBID

	}

	if o.R == nil {
		o.R = &dbR{
			Dbxref: related,
		}
	} else {
		o.R.Dbxref = related
	}

	if related.R == nil {
		related.R = &dbxrefR{
			DB: o,
		}
	} else {
		related.R.DB = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:db.go


示例13: SetEnvironment2PhenotypeComparison

// SetEnvironment2PhenotypeComparison of the environment to the related item.
// Sets o.R.Environment2PhenotypeComparison to related.
// Adds o to related.R.Environment2.
func (o *Environment) SetEnvironment2PhenotypeComparison(exec boil.Executor, insert bool, related *PhenotypeComparison) error {
	var err error

	if insert {
		related.Environment2ID = o.EnvironmentID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"phenotype_comparison\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"environment2_id"}),
			strmangle.WhereClause("\"", "\"", 2, phenotypeComparisonPrimaryKeyColumns),
		)
		values := []interface{}{o.EnvironmentID, related.PhenotypeComparisonID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.Environment2ID = o.EnvironmentID

	}

	if o.R == nil {
		o.R = &environmentR{
			Environment2PhenotypeComparison: related,
		}
	} else {
		o.R.Environment2PhenotypeComparison = related
	}

	if related.R == nil {
		related.R = &phenotypeComparisonR{
			Environment2: o,
		}
	} else {
		related.R.Environment2 = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:environment.go


示例14: SetSubjectContactRelationship

// SetSubjectContactRelationship of the contact to the related item.
// Sets o.R.SubjectContactRelationship to related.
// Adds o to related.R.Subject.
func (o *Contact) SetSubjectContactRelationship(exec boil.Executor, insert bool, related *ContactRelationship) error {
	var err error

	if insert {
		related.SubjectID = o.ContactID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"contact_relationship\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"subject_id"}),
			strmangle.WhereClause("\"", "\"", 2, contactRelationshipPrimaryKeyColumns),
		)
		values := []interface{}{o.ContactID, related.ContactRelationshipID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.SubjectID = o.ContactID

	}

	if o.R == nil {
		o.R = &contactR{
			SubjectContactRelationship: related,
		}
	} else {
		o.R.SubjectContactRelationship = related
	}

	if related.R == nil {
		related.R = &contactRelationshipR{
			Subject: o,
		}
	} else {
		related.R.Subject = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:contact.go


示例15: SetAnalysisfeature

// SetAnalysisfeature of the analysi to the related item.
// Sets o.R.Analysisfeature to related.
// Adds o to related.R.Analysi.
func (o *Analysi) SetAnalysisfeature(exec boil.Executor, insert bool, related *Analysisfeature) error {
	var err error

	if insert {
		related.AnalysisID = o.AnalysisID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"analysisfeature\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"analysis_id"}),
			strmangle.WhereClause("\"", "\"", 2, analysisfeaturePrimaryKeyColumns),
		)
		values := []interface{}{o.AnalysisID, related.AnalysisfeatureID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.AnalysisID = o.AnalysisID

	}

	if o.R == nil {
		o.R = &analysiR{
			Analysisfeature: related,
		}
	} else {
		o.R.Analysisfeature = related
	}

	if related.R == nil {
		related.R = &analysisfeatureR{
			Analysi: o,
		}
	} else {
		related.R.Analysi = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:analysis.go


示例16: SetStockcollectionprop

// SetStockcollectionprop of the stockcollection to the related item.
// Sets o.R.Stockcollectionprop to related.
// Adds o to related.R.Stockcollection.
func (o *Stockcollection) SetStockcollectionprop(exec boil.Executor, insert bool, related *Stockcollectionprop) error {
	var err error

	if insert {
		related.StockcollectionID = o.StockcollectionID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"stockcollectionprop\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"stockcollection_id"}),
			strmangle.WhereClause("\"", "\"", 2, stockcollectionpropPrimaryKeyColumns),
		)
		values := []interface{}{o.StockcollectionID, related.StockcollectionpropID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.StockcollectionID = o.StockcollectionID

	}

	if o.R == nil {
		o.R = &stockcollectionR{
			Stockcollectionprop: related,
		}
	} else {
		o.R.Stockcollectionprop = related
	}

	if related.R == nil {
		related.R = &stockcollectionpropR{
			Stockcollection: o,
		}
	} else {
		related.R.Stockcollection = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:stockcollection.go


示例17: SetFeaturepropPub

// SetFeaturepropPub of the featureprop to the related item.
// Sets o.R.FeaturepropPub to related.
// Adds o to related.R.Featureprop.
func (o *Featureprop) SetFeaturepropPub(exec boil.Executor, insert bool, related *FeaturepropPub) error {
	var err error

	if insert {
		related.FeaturepropID = o.FeaturepropID

		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	} else {
		updateQuery := fmt.Sprintf(
			"UPDATE \"featureprop_pub\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, []string{"featureprop_id"}),
			strmangle.WhereClause("\"", "\"", 2, featurepropPubPrimaryKeyColumns),
		)
		values := []interface{}{o.FeaturepropID, related.FeaturepropPubID}

		if boil.DebugMode {
			fmt.Fprintln(boil.DebugWriter, updateQuery)
			fmt.Fprintln(boil.DebugWriter, values)
		}

		if _, err = exec.Exec(updateQuery, values...); err != nil {
			return errors.Wrap(err, "failed to update foreign table")
		}

		related.FeaturepropID = o.FeaturepropID

	}

	if o.R == nil {
		o.R = &featurepropR{
			FeaturepropPub: related,
		}
	} else {
		o.R.FeaturepropPub = related
	}

	if related.R == nil {
		related.R = &featurepropPubR{
			Featureprop: o,
		}
	} else {
		related.R.Featureprop = o
	}
	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:50,代码来源:featureprop.go


示例18: Update

// Update uses an executor to update the FeaturepropPub.
// Whitelist behavior: If a whitelist is provided, only the columns given are updated.
// No whitelist behavior: Without a whitelist, columns are inferred by the following rules:
// - All columns are inferred to start with
// - All primary keys are subtracted from this set
// Update does not automatically update the record in case of default values. Use .Reload()
// to refresh the records.
func (o *FeaturepropPub) Update(exec boil.Executor, whitelist ...string) error {
	var err error
	if err = o.doBeforeUpdateHooks(exec); err != nil {
		return err
	}
	key := makeCacheKey(whitelist, nil)
	featurepropPubUpdateCacheMut.RLock()
	cache, cached := featurepropPubUpdateCache[key]
	featurepropPubUpdateCacheMut.RUnlock()

	if !cached {
		wl := strmangle.UpdateColumnSet(featurepropPubColumns, featurepropPubPrimaryKeyColumns, whitelist)
		if len(wl) == 0 {
			return errors.New("chado: unable to update featureprop_pub, could not build whitelist")
		}

		cache.query = fmt.Sprintf("UPDATE \"featureprop_pub\" SET %s WHERE %s",
			strmangle.SetParamNames("\"", "\"", 1, wl),
			strmangle.WhereClause("\"", "\"", len(wl)+1, featurepropPubPrimaryKeyColumns),
		)
		cache.valueMapping, err = queries.BindMapping(featurepropPubType, featurepropPubMapping, append(wl, featurepropPubPrimaryKeyColumns...))
		if err != nil {
			return err
		}
	}

	values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping)

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.query)
		fmt.Fprintln(boil.DebugWriter, values)
	}

	_, err = exec.Exec(cache.query, values...)
	if err != nil {
		return errors.Wrap(err, "chado: unable to update featureprop_pub row")
	}

	if !cached {
		featurepropPubUpdateCacheMut.Lock()
		featurepropPubUpdateCache[key] = cache
		featurepropPubUpdateCacheMut.Unlock()
	}

	return o.doAfterUpdateHooks(exec)
}
开发者ID:dictyBase,项目名称:Modware,代码行数:53,代码来源:featureprop_pub.go


示例19: SetType

// SetType of the contact to the related item.
// Sets o.R.Type to related.
// Adds o to related.R.TypeContacts.
func (o *Contact) SetType(exec boil.Executor, insert bool, related *Cvterm) error {
	var err error
	if insert {
		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}

	updateQuery := fmt.Sprintf(
		"UPDATE \"contact\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"type_id"}),
		strmangle.WhereClause("\"", "\"", 2, contactPrimaryKeyColumns),
	)
	values := []interface{}{related.CvtermID, o.ContactID}

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, updateQuery)
		fmt.Fprintln(boil.DebugWriter, values)
	}

	if _, err = exec.Exec(updateQuery, values...); err != nil {
		return errors.Wrap(err, "failed to update local table")
	}

	o.TypeID.Int = related.CvtermID
	o.TypeID.Valid = true

	if o.R == nil {
		o.R = &contactR{
			Type: related,
		}
	} else {
		o.R.Type = related
	}

	if related.R == nil {
		related.R = &cvtermR{
			TypeContacts: ContactSlice{o},
		}
	} else {
		related.R.TypeContacts = append(related.R.TypeContacts, o)
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:48,代码来源:contact.go


示例20: SetContact

// SetContact of the stockcollection to the related item.
// Sets o.R.Contact to related.
// Adds o to related.R.Stockcollections.
func (o *Stockcollection) SetContact(exec boil.Executor, insert bool, related *Contact) error {
	var err error
	if insert {
		if err = related.Insert(exec); err != nil {
			return errors.Wrap(err, "failed to insert into foreign table")
		}
	}

	updateQuery := fmt.Sprintf(
		"UPDATE \"stockcollection\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"contact_id"}),
		strmangle.WhereClause("\"", "\"", 2, stockcollectionPrimaryKeyColumns),
	)
	values := []interface{}{related.ContactID, o.StockcollectionID}

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, updateQuery)
		fmt.Fprintln(boil.DebugWriter, values)
	}

	if _, err = exec.Exec(updateQuery, values...); err != nil {
		return errors.Wrap(err, "failed to update local table")
	}

	o.ContactID.Int = related.ContactID
	o.ContactID.Valid = true

	if o.R == nil {
		o.R = &stockcollectionR{
			Contact: related,
		}
	} else {
		o.R.Contact = related
	}

	if related.R == nil {
		related.R = &contactR{
			Stockcollections: StockcollectionSlice{o},
		}
	} else {
		related.R.Stockcollections = append(related.R.Stockcollections, o)
	}

	return nil
}
开发者ID:dictyBase,项目名称:Modware,代码行数:48,代码来源:stockcollection.go



注:本文中的github.com/vattle/sqlboiler/boil.Executor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang queries.Bind函数代码示例发布时间:2022-05-28
下一篇:
Golang boil.WrapErr函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap