本文整理汇总了Golang中github.com/vattle/sqlboiler/boil.Executor类的典型用法代码示例。如果您正苦于以下问题:Golang Executor类的具体用法?Golang Executor怎么用?Golang Executor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Executor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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...)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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...)
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}