本文整理汇总了Golang中github.com/vattle/sqlboiler/strmangle.SetParamNames函数的典型用法代码示例。如果您正苦于以下问题:Golang SetParamNames函数的具体用法?Golang SetParamNames怎么用?Golang SetParamNames使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetParamNames函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例2: 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
}
示例3: 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
}
示例4: 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
}
示例5: 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
}
示例6: 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
}
示例7: 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
}
示例8: 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
}
示例9: 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
}
示例10: 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
}
示例11: 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)
}
示例12: SetFile
// SetFile of the download to the related item.
// Sets o.R.File to related.
// Adds o to related.R.Downloads.
func (o *Download) SetFile(exec boil.Executor, insert bool, related *File) 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 \"downloads\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 1, []string{"file_id"}),
strmangle.WhereClause("\"", "\"", 2, downloadPrimaryKeyColumns),
)
values := []interface{}{related.ID, o.ID}
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.FileID.String = related.ID
o.FileID.Valid = true
if o.R == nil {
o.R = &downloadR{
File: related,
}
} else {
o.R.File = related
}
if related.R == nil {
related.R = &fileR{
Downloads: DownloadSlice{o},
}
} else {
related.R.Downloads = append(related.R.Downloads, o)
}
return nil
}
示例13: SetPub
// SetPub of the stock_relationship_cvterm to the related item.
// Sets o.R.Pub to related.
// Adds o to related.R.StockRelationshipCvterms.
func (o *StockRelationshipCvterm) SetPub(exec boil.Executor, insert bool, related *Pub) 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 \"stock_relationship_cvterm\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 1, []string{"pub_id"}),
strmangle.WhereClause("\"", "\"", 2, stockRelationshipCvtermPrimaryKeyColumns),
)
values := []interface{}{related.PubID, o.StockRelationshipCvtermID}
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.PubID.Int = related.PubID
o.PubID.Valid = true
if o.R == nil {
o.R = &stockRelationshipCvtermR{
Pub: related,
}
} else {
o.R.Pub = related
}
if related.R == nil {
related.R = &pubR{
StockRelationshipCvterms: StockRelationshipCvtermSlice{o},
}
} else {
related.R.StockRelationshipCvterms = append(related.R.StockRelationshipCvterms, o)
}
return nil
}
示例14: SetChromosome
// SetChromosome of the feature_genotype to the related item.
// Sets o.R.Chromosome to related.
// Adds o to related.R.ChromosomeFeatureGenotype.
func (o *FeatureGenotype) SetChromosome(exec boil.Executor, insert bool, related *Feature) 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 \"feature_genotype\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 1, []string{"chromosome_id"}),
strmangle.WhereClause("\"", "\"", 2, featureGenotypePrimaryKeyColumns),
)
values := []interface{}{related.FeatureID, o.FeatureGenotypeID}
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.ChromosomeID.Int = related.FeatureID
o.ChromosomeID.Valid = true
if o.R == nil {
o.R = &featureGenotypeR{
Chromosome: related,
}
} else {
o.R.Chromosome = related
}
if related.R == nil {
related.R = &featureR{
ChromosomeFeatureGenotype: o,
}
} else {
related.R.ChromosomeFeatureGenotype = o
}
return nil
}
示例15: 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
}