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

Golang queries.BindMapping函数代码示例

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

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



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

示例1: 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


示例2: 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


示例3:

	// PhenotypepropSlice is an alias for a slice of pointers to Phenotypeprop.
	// This should generally be used opposed to []Phenotypeprop.
	PhenotypepropSlice []*Phenotypeprop
	// PhenotypepropHook is the signature for custom Phenotypeprop hook methods
	PhenotypepropHook func(boil.Executor, *Phenotypeprop) error

	phenotypepropQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	phenotypepropType                 = reflect.TypeOf(&Phenotypeprop{})
	phenotypepropMapping              = queries.MakeStructMapping(phenotypepropType)
	phenotypepropPrimaryKeyMapping, _ = queries.BindMapping(phenotypepropType, phenotypepropMapping, phenotypepropPrimaryKeyColumns)
	phenotypepropInsertCacheMut       sync.RWMutex
	phenotypepropInsertCache          = make(map[string]insertCache)
	phenotypepropUpdateCacheMut       sync.RWMutex
	phenotypepropUpdateCache          = make(map[string]updateCache)
	phenotypepropUpsertCacheMut       sync.RWMutex
	phenotypepropUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var phenotypepropBeforeInsertHooks []PhenotypepropHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:phenotypeprop.go


示例4:

	// FeaturepropPubSlice is an alias for a slice of pointers to FeaturepropPub.
	// This should generally be used opposed to []FeaturepropPub.
	FeaturepropPubSlice []*FeaturepropPub
	// FeaturepropPubHook is the signature for custom FeaturepropPub hook methods
	FeaturepropPubHook func(boil.Executor, *FeaturepropPub) error

	featurepropPubQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	featurepropPubType                 = reflect.TypeOf(&FeaturepropPub{})
	featurepropPubMapping              = queries.MakeStructMapping(featurepropPubType)
	featurepropPubPrimaryKeyMapping, _ = queries.BindMapping(featurepropPubType, featurepropPubMapping, featurepropPubPrimaryKeyColumns)
	featurepropPubInsertCacheMut       sync.RWMutex
	featurepropPubInsertCache          = make(map[string]insertCache)
	featurepropPubUpdateCacheMut       sync.RWMutex
	featurepropPubUpdateCache          = make(map[string]updateCache)
	featurepropPubUpsertCacheMut       sync.RWMutex
	featurepropPubUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var featurepropPubBeforeInsertHooks []FeaturepropPubHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:featureprop_pub.go


示例5:

	// TableinfoSlice is an alias for a slice of pointers to Tableinfo.
	// This should generally be used opposed to []Tableinfo.
	TableinfoSlice []*Tableinfo
	// TableinfoHook is the signature for custom Tableinfo hook methods
	TableinfoHook func(boil.Executor, *Tableinfo) error

	tableinfoQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	tableinfoType                 = reflect.TypeOf(&Tableinfo{})
	tableinfoMapping              = queries.MakeStructMapping(tableinfoType)
	tableinfoPrimaryKeyMapping, _ = queries.BindMapping(tableinfoType, tableinfoMapping, tableinfoPrimaryKeyColumns)
	tableinfoInsertCacheMut       sync.RWMutex
	tableinfoInsertCache          = make(map[string]insertCache)
	tableinfoUpdateCacheMut       sync.RWMutex
	tableinfoUpdateCache          = make(map[string]updateCache)
	tableinfoUpsertCacheMut       sync.RWMutex
	tableinfoUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var tableinfoBeforeInsertHooks []TableinfoHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:tableinfo.go


示例6:

	// FeatureCvtermpropSlice is an alias for a slice of pointers to FeatureCvtermprop.
	// This should generally be used opposed to []FeatureCvtermprop.
	FeatureCvtermpropSlice []*FeatureCvtermprop
	// FeatureCvtermpropHook is the signature for custom FeatureCvtermprop hook methods
	FeatureCvtermpropHook func(boil.Executor, *FeatureCvtermprop) error

	featureCvtermpropQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	featureCvtermpropType                 = reflect.TypeOf(&FeatureCvtermprop{})
	featureCvtermpropMapping              = queries.MakeStructMapping(featureCvtermpropType)
	featureCvtermpropPrimaryKeyMapping, _ = queries.BindMapping(featureCvtermpropType, featureCvtermpropMapping, featureCvtermpropPrimaryKeyColumns)
	featureCvtermpropInsertCacheMut       sync.RWMutex
	featureCvtermpropInsertCache          = make(map[string]insertCache)
	featureCvtermpropUpdateCacheMut       sync.RWMutex
	featureCvtermpropUpdateCache          = make(map[string]updateCache)
	featureCvtermpropUpsertCacheMut       sync.RWMutex
	featureCvtermpropUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var featureCvtermpropBeforeInsertHooks []FeatureCvtermpropHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:feature_cvtermprop.go


示例7:

	// AnalysisfeatureSlice is an alias for a slice of pointers to Analysisfeature.
	// This should generally be used opposed to []Analysisfeature.
	AnalysisfeatureSlice []*Analysisfeature
	// AnalysisfeatureHook is the signature for custom Analysisfeature hook methods
	AnalysisfeatureHook func(boil.Executor, *Analysisfeature) error

	analysisfeatureQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	analysisfeatureType                 = reflect.TypeOf(&Analysisfeature{})
	analysisfeatureMapping              = queries.MakeStructMapping(analysisfeatureType)
	analysisfeaturePrimaryKeyMapping, _ = queries.BindMapping(analysisfeatureType, analysisfeatureMapping, analysisfeaturePrimaryKeyColumns)
	analysisfeatureInsertCacheMut       sync.RWMutex
	analysisfeatureInsertCache          = make(map[string]insertCache)
	analysisfeatureUpdateCacheMut       sync.RWMutex
	analysisfeatureUpdateCache          = make(map[string]updateCache)
	analysisfeatureUpsertCacheMut       sync.RWMutex
	analysisfeatureUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var analysisfeatureBeforeInsertHooks []AnalysisfeatureHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:analysisfeature.go


示例8:

	// StockcollectionSlice is an alias for a slice of pointers to Stockcollection.
	// This should generally be used opposed to []Stockcollection.
	StockcollectionSlice []*Stockcollection
	// StockcollectionHook is the signature for custom Stockcollection hook methods
	StockcollectionHook func(boil.Executor, *Stockcollection) error

	stockcollectionQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	stockcollectionType                 = reflect.TypeOf(&Stockcollection{})
	stockcollectionMapping              = queries.MakeStructMapping(stockcollectionType)
	stockcollectionPrimaryKeyMapping, _ = queries.BindMapping(stockcollectionType, stockcollectionMapping, stockcollectionPrimaryKeyColumns)
	stockcollectionInsertCacheMut       sync.RWMutex
	stockcollectionInsertCache          = make(map[string]insertCache)
	stockcollectionUpdateCacheMut       sync.RWMutex
	stockcollectionUpdateCache          = make(map[string]updateCache)
	stockcollectionUpsertCacheMut       sync.RWMutex
	stockcollectionUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var stockcollectionBeforeInsertHooks []StockcollectionHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:stockcollection.go


示例9:

	// FileSlice is an alias for a slice of pointers to File.
	// This should generally be used opposed to []File.
	FileSlice []*File
	// FileHook is the signature for custom File hook methods
	FileHook func(boil.Executor, *File) error

	fileQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	fileType                 = reflect.TypeOf(&File{})
	fileMapping              = queries.MakeStructMapping(fileType)
	filePrimaryKeyMapping, _ = queries.BindMapping(fileType, fileMapping, filePrimaryKeyColumns)
	fileInsertCacheMut       sync.RWMutex
	fileInsertCache          = make(map[string]insertCache)
	fileUpdateCacheMut       sync.RWMutex
	fileUpdateCache          = make(map[string]updateCache)
	fileUpsertCacheMut       sync.RWMutex
	fileUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var fileBeforeInsertHooks []FileHook
开发者ID:zqzca,项目名称:back,代码行数:31,代码来源:files.go


示例10:

	// PubRelationshipSlice is an alias for a slice of pointers to PubRelationship.
	// This should generally be used opposed to []PubRelationship.
	PubRelationshipSlice []*PubRelationship
	// PubRelationshipHook is the signature for custom PubRelationship hook methods
	PubRelationshipHook func(boil.Executor, *PubRelationship) error

	pubRelationshipQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	pubRelationshipType                 = reflect.TypeOf(&PubRelationship{})
	pubRelationshipMapping              = queries.MakeStructMapping(pubRelationshipType)
	pubRelationshipPrimaryKeyMapping, _ = queries.BindMapping(pubRelationshipType, pubRelationshipMapping, pubRelationshipPrimaryKeyColumns)
	pubRelationshipInsertCacheMut       sync.RWMutex
	pubRelationshipInsertCache          = make(map[string]insertCache)
	pubRelationshipUpdateCacheMut       sync.RWMutex
	pubRelationshipUpdateCache          = make(map[string]updateCache)
	pubRelationshipUpsertCacheMut       sync.RWMutex
	pubRelationshipUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var pubRelationshipBeforeInsertHooks []PubRelationshipHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:pub_relationship.go


示例11:

	// PubpropSlice is an alias for a slice of pointers to Pubprop.
	// This should generally be used opposed to []Pubprop.
	PubpropSlice []*Pubprop
	// PubpropHook is the signature for custom Pubprop hook methods
	PubpropHook func(boil.Executor, *Pubprop) error

	pubpropQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	pubpropType                 = reflect.TypeOf(&Pubprop{})
	pubpropMapping              = queries.MakeStructMapping(pubpropType)
	pubpropPrimaryKeyMapping, _ = queries.BindMapping(pubpropType, pubpropMapping, pubpropPrimaryKeyColumns)
	pubpropInsertCacheMut       sync.RWMutex
	pubpropInsertCache          = make(map[string]insertCache)
	pubpropUpdateCacheMut       sync.RWMutex
	pubpropUpdateCache          = make(map[string]updateCache)
	pubpropUpsertCacheMut       sync.RWMutex
	pubpropUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var pubpropBeforeInsertHooks []PubpropHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:pubprop.go


示例12:

	// PhenstatementSlice is an alias for a slice of pointers to Phenstatement.
	// This should generally be used opposed to []Phenstatement.
	PhenstatementSlice []*Phenstatement
	// PhenstatementHook is the signature for custom Phenstatement hook methods
	PhenstatementHook func(boil.Executor, *Phenstatement) error

	phenstatementQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	phenstatementType                 = reflect.TypeOf(&Phenstatement{})
	phenstatementMapping              = queries.MakeStructMapping(phenstatementType)
	phenstatementPrimaryKeyMapping, _ = queries.BindMapping(phenstatementType, phenstatementMapping, phenstatementPrimaryKeyColumns)
	phenstatementInsertCacheMut       sync.RWMutex
	phenstatementInsertCache          = make(map[string]insertCache)
	phenstatementUpdateCacheMut       sync.RWMutex
	phenstatementUpdateCache          = make(map[string]updateCache)
	phenstatementUpsertCacheMut       sync.RWMutex
	phenstatementUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var phenstatementBeforeInsertHooks []PhenstatementHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:phenstatement.go


示例13:

	// AuthUserInfoSlice is an alias for a slice of pointers to AuthUserInfo.
	// This should generally be used opposed to []AuthUserInfo.
	AuthUserInfoSlice []*AuthUserInfo
	// AuthUserInfoHook is the signature for custom AuthUserInfo hook methods
	AuthUserInfoHook func(boil.Executor, *AuthUserInfo) error

	authUserInfoQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	authUserInfoType                 = reflect.TypeOf(&AuthUserInfo{})
	authUserInfoMapping              = queries.MakeStructMapping(authUserInfoType)
	authUserInfoPrimaryKeyMapping, _ = queries.BindMapping(authUserInfoType, authUserInfoMapping, authUserInfoPrimaryKeyColumns)
	authUserInfoInsertCacheMut       sync.RWMutex
	authUserInfoInsertCache          = make(map[string]insertCache)
	authUserInfoUpdateCacheMut       sync.RWMutex
	authUserInfoUpdateCache          = make(map[string]updateCache)
	authUserInfoUpsertCacheMut       sync.RWMutex
	authUserInfoUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var authUserInfoBeforeInsertHooks []AuthUserInfoHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:auth_user_info.go


示例14:

	// EnvironmentCvtermSlice is an alias for a slice of pointers to EnvironmentCvterm.
	// This should generally be used opposed to []EnvironmentCvterm.
	EnvironmentCvtermSlice []*EnvironmentCvterm
	// EnvironmentCvtermHook is the signature for custom EnvironmentCvterm hook methods
	EnvironmentCvtermHook func(boil.Executor, *EnvironmentCvterm) error

	environmentCvtermQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	environmentCvtermType                 = reflect.TypeOf(&EnvironmentCvterm{})
	environmentCvtermMapping              = queries.MakeStructMapping(environmentCvtermType)
	environmentCvtermPrimaryKeyMapping, _ = queries.BindMapping(environmentCvtermType, environmentCvtermMapping, environmentCvtermPrimaryKeyColumns)
	environmentCvtermInsertCacheMut       sync.RWMutex
	environmentCvtermInsertCache          = make(map[string]insertCache)
	environmentCvtermUpdateCacheMut       sync.RWMutex
	environmentCvtermUpdateCache          = make(map[string]updateCache)
	environmentCvtermUpsertCacheMut       sync.RWMutex
	environmentCvtermUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var environmentCvtermBeforeInsertHooks []EnvironmentCvtermHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:environment_cvterm.go


示例15:

	// CvtermpropSlice is an alias for a slice of pointers to Cvtermprop.
	// This should generally be used opposed to []Cvtermprop.
	CvtermpropSlice []*Cvtermprop
	// CvtermpropHook is the signature for custom Cvtermprop hook methods
	CvtermpropHook func(boil.Executor, *Cvtermprop) error

	cvtermpropQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	cvtermpropType                 = reflect.TypeOf(&Cvtermprop{})
	cvtermpropMapping              = queries.MakeStructMapping(cvtermpropType)
	cvtermpropPrimaryKeyMapping, _ = queries.BindMapping(cvtermpropType, cvtermpropMapping, cvtermpropPrimaryKeyColumns)
	cvtermpropInsertCacheMut       sync.RWMutex
	cvtermpropInsertCache          = make(map[string]insertCache)
	cvtermpropUpdateCacheMut       sync.RWMutex
	cvtermpropUpdateCache          = make(map[string]updateCache)
	cvtermpropUpsertCacheMut       sync.RWMutex
	cvtermpropUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var cvtermpropBeforeInsertHooks []CvtermpropHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:cvtermprop.go


示例16:

	// CVSlice is an alias for a slice of pointers to CV.
	// This should generally be used opposed to []CV.
	CVSlice []*CV
	// CVHook is the signature for custom CV hook methods
	CVHook func(boil.Executor, *CV) error

	cvQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	cvType                 = reflect.TypeOf(&CV{})
	cvMapping              = queries.MakeStructMapping(cvType)
	cvPrimaryKeyMapping, _ = queries.BindMapping(cvType, cvMapping, cvPrimaryKeyColumns)
	cvInsertCacheMut       sync.RWMutex
	cvInsertCache          = make(map[string]insertCache)
	cvUpdateCacheMut       sync.RWMutex
	cvUpdateCache          = make(map[string]updateCache)
	cvUpsertCacheMut       sync.RWMutex
	cvUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var cvBeforeInsertHooks []CVHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:cv.go


示例17: Upsert

// Upsert attempts an insert using an executor, and does an update or ignore on conflict.
func (o *AuthRolePermission) Upsert(exec boil.Executor, updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) error {
	if o == nil {
		return errors.New("chado: no auth_role_permission provided for upsert")
	}
	currTime := time.Now().In(boil.GetLocation())

	if o.CreatedAt.Time.IsZero() {
		o.CreatedAt.Time = currTime
		o.CreatedAt.Valid = true
	}
	o.UpdatedAt.Time = currTime
	o.UpdatedAt.Valid = true

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

	nzDefaults := queries.NonZeroDefaultSet(authRolePermissionColumnsWithDefault, o)

	// Build cache key in-line uglily - mysql vs postgres problems
	buf := strmangle.GetBuffer()
	if updateOnConflict {
		buf.WriteByte('t')
	} else {
		buf.WriteByte('f')
	}
	buf.WriteByte('.')
	for _, c := range conflictColumns {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range updateColumns {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range whitelist {
		buf.WriteString(c)
	}
	buf.WriteByte('.')
	for _, c := range nzDefaults {
		buf.WriteString(c)
	}
	key := buf.String()
	strmangle.PutBuffer(buf)

	authRolePermissionUpsertCacheMut.RLock()
	cache, cached := authRolePermissionUpsertCache[key]
	authRolePermissionUpsertCacheMut.RUnlock()

	var err error

	if !cached {
		var ret []string
		whitelist, ret = strmangle.InsertColumnSet(
			authRolePermissionColumns,
			authRolePermissionColumnsWithDefault,
			authRolePermissionColumnsWithoutDefault,
			nzDefaults,
			whitelist,
		)
		update := strmangle.UpdateColumnSet(
			authRolePermissionColumns,
			authRolePermissionPrimaryKeyColumns,
			updateColumns,
		)
		if len(update) == 0 {
			return errors.New("chado: unable to upsert auth_role_permission, could not build update column list")
		}

		conflict := conflictColumns
		if len(conflict) == 0 {
			conflict = make([]string, len(authRolePermissionPrimaryKeyColumns))
			copy(conflict, authRolePermissionPrimaryKeyColumns)
		}
		cache.query = queries.BuildUpsertQueryPostgres(dialect, "\"auth_role_permission\"", updateOnConflict, ret, update, conflict, whitelist)

		cache.valueMapping, err = queries.BindMapping(authRolePermissionType, authRolePermissionMapping, whitelist)
		if err != nil {
			return err
		}
		if len(ret) != 0 {
			cache.retMapping, err = queries.BindMapping(authRolePermissionType, authRolePermissionMapping, ret)
			if err != nil {
				return err
			}
		}
	}

	value := reflect.Indirect(reflect.ValueOf(o))
	vals := queries.ValuesFromMapping(value, cache.valueMapping)
	var returns []interface{}
	if len(cache.retMapping) != 0 {
		returns = queries.PtrsFromMapping(value, cache.retMapping)
	}

	if boil.DebugMode {
		fmt.Fprintln(boil.DebugWriter, cache.query)
		fmt.Fprintln(boil.DebugWriter, vals)
	}
//.........这里部分代码省略.........
开发者ID:dictyBase,项目名称:Modware,代码行数:101,代码来源:auth_role_permission.go


示例18:

	// DbxrefpropSlice is an alias for a slice of pointers to Dbxrefprop.
	// This should generally be used opposed to []Dbxrefprop.
	DbxrefpropSlice []*Dbxrefprop
	// DbxrefpropHook is the signature for custom Dbxrefprop hook methods
	DbxrefpropHook func(boil.Executor, *Dbxrefprop) error

	dbxrefpropQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	dbxrefpropType                 = reflect.TypeOf(&Dbxrefprop{})
	dbxrefpropMapping              = queries.MakeStructMapping(dbxrefpropType)
	dbxrefpropPrimaryKeyMapping, _ = queries.BindMapping(dbxrefpropType, dbxrefpropMapping, dbxrefpropPrimaryKeyColumns)
	dbxrefpropInsertCacheMut       sync.RWMutex
	dbxrefpropInsertCache          = make(map[string]insertCache)
	dbxrefpropUpdateCacheMut       sync.RWMutex
	dbxrefpropUpdateCache          = make(map[string]updateCache)
	dbxrefpropUpsertCacheMut       sync.RWMutex
	dbxrefpropUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var dbxrefpropBeforeInsertHooks []DbxrefpropHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:dbxrefprop.go


示例19:

	// ContactSlice is an alias for a slice of pointers to Contact.
	// This should generally be used opposed to []Contact.
	ContactSlice []*Contact
	// ContactHook is the signature for custom Contact hook methods
	ContactHook func(boil.Executor, *Contact) error

	contactQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	contactType                 = reflect.TypeOf(&Contact{})
	contactMapping              = queries.MakeStructMapping(contactType)
	contactPrimaryKeyMapping, _ = queries.BindMapping(contactType, contactMapping, contactPrimaryKeyColumns)
	contactInsertCacheMut       sync.RWMutex
	contactInsertCache          = make(map[string]insertCache)
	contactUpdateCacheMut       sync.RWMutex
	contactUpdateCache          = make(map[string]updateCache)
	contactUpsertCacheMut       sync.RWMutex
	contactUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var contactBeforeInsertHooks []ContactHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:contact.go


示例20:

	// StockCvtermSlice is an alias for a slice of pointers to StockCvterm.
	// This should generally be used opposed to []StockCvterm.
	StockCvtermSlice []*StockCvterm
	// StockCvtermHook is the signature for custom StockCvterm hook methods
	StockCvtermHook func(boil.Executor, *StockCvterm) error

	stockCvtermQuery struct {
		*queries.Query
	}
)

// Cache for insert, update and upsert
var (
	stockCvtermType                 = reflect.TypeOf(&StockCvterm{})
	stockCvtermMapping              = queries.MakeStructMapping(stockCvtermType)
	stockCvtermPrimaryKeyMapping, _ = queries.BindMapping(stockCvtermType, stockCvtermMapping, stockCvtermPrimaryKeyColumns)
	stockCvtermInsertCacheMut       sync.RWMutex
	stockCvtermInsertCache          = make(map[string]insertCache)
	stockCvtermUpdateCacheMut       sync.RWMutex
	stockCvtermUpdateCache          = make(map[string]updateCache)
	stockCvtermUpsertCacheMut       sync.RWMutex
	stockCvtermUpsertCache          = make(map[string]insertCache)
)

var (
	// Force time package dependency for automated UpdatedAt/CreatedAt.
	_ = time.Second
	// Force bytes in case of primary key column that uses []byte (for relationship compares)
	_ = bytes.MinRead
)
var stockCvtermBeforeInsertHooks []StockCvtermHook
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:stock_cvterm.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang queries.BuildUpsertQueryPostgres函数代码示例发布时间:2022-05-28
下一篇:
Golang queries.Bind函数代码示例发布时间: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