Example #1
0
// 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...)
}
// 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
}
Example #3
0
// 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
}
// 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
}
Example #5
0
// 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
}
Example #6
0
File: files.go Project: zqzca/back
// 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...)
}
// 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)
}
Example #8
0
// 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
}
Example #9
0
// 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
}
Example #10
0
// 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
}
Example #11
0
// 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
}
Example #12
0
// 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
}
Example #13
0
// 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
}
Example #14
0
// 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
}
Example #15
0
// 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
}
Example #16
0
// 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
}
Example #17
0
// 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
}
Example #18
0
// 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)
}
Example #19
0
// 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
}
Example #20
0
// 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
}
Example #21
0
// 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
}
Example #22
0
// 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
}
// 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
}
Example #24
0
// SetPhenotype of the phenstatement to the related item.
// Sets o.R.Phenotype to related.
// Adds o to related.R.Phenstatement.
func (o *Phenstatement) SetPhenotype(exec boil.Executor, insert bool, related *Phenotype) 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 \"phenstatement\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"phenotype_id"}),
		strmangle.WhereClause("\"", "\"", 2, phenstatementPrimaryKeyColumns),
	)
	values := []interface{}{related.PhenotypeID, o.PhenstatementID}

	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.PhenotypeID = related.PhenotypeID

	if o.R == nil {
		o.R = &phenstatementR{
			Phenotype: related,
		}
	} else {
		o.R.Phenotype = related
	}

	if related.R == nil {
		related.R = &phenotypeR{
			Phenstatement: o,
		}
	} else {
		related.R.Phenstatement = o
	}

	return nil
}
Example #25
0
// UpdateAll updates all rows with the specified column values, using an executor.
func (o FeaturepropPubSlice) UpdateAll(exec boil.Executor, cols M) error {
	ln := int64(len(o))
	if ln == 0 {
		return nil
	}

	if len(cols) == 0 {
		return errors.New("chado: update all requires at least one column argument")
	}

	colNames := make([]string, len(cols))
	args := make([]interface{}, len(cols))

	i := 0
	for name, value := range cols {
		colNames[i] = name
		args[i] = value
		i++
	}

	// Append all of the primary key values for each column
	for _, obj := range o {
		pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), featurepropPubPrimaryKeyMapping)
		args = append(args, pkeyArgs...)
	}

	sql := fmt.Sprintf(
		"UPDATE \"featureprop_pub\" SET %s WHERE (\"featureprop_pub_id\") IN (%s)",
		strmangle.SetParamNames("\"", "\"", 1, colNames),
		strmangle.Placeholders(dialect.IndexPlaceholders, len(o)*len(featurepropPubPrimaryKeyColumns), len(colNames)+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 update all in featurepropPub slice")
	}

	return nil
}
Example #26
0
// SetObject of the pub_relationship to the related item.
// Sets o.R.Object to related.
// Adds o to related.R.ObjectPubRelationship.
func (o *PubRelationship) SetObject(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 \"pub_relationship\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"object_id"}),
		strmangle.WhereClause("\"", "\"", 2, pubRelationshipPrimaryKeyColumns),
	)
	values := []interface{}{related.PubID, o.PubRelationshipID}

	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.ObjectID = related.PubID

	if o.R == nil {
		o.R = &pubRelationshipR{
			Object: related,
		}
	} else {
		o.R.Object = related
	}

	if related.R == nil {
		related.R = &pubR{
			ObjectPubRelationship: o,
		}
	} else {
		related.R.ObjectPubRelationship = o
	}

	return nil
}
Example #27
0
// SetStock of the stock_cvterm to the related item.
// Sets o.R.Stock to related.
// Adds o to related.R.StockCvterm.
func (o *StockCvterm) SetStock(exec boil.Executor, insert bool, related *Stock) 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_cvterm\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"stock_id"}),
		strmangle.WhereClause("\"", "\"", 2, stockCvtermPrimaryKeyColumns),
	)
	values := []interface{}{related.StockID, o.StockCvtermID}

	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.StockID = related.StockID

	if o.R == nil {
		o.R = &stockCvtermR{
			Stock: related,
		}
	} else {
		o.R.Stock = related
	}

	if related.R == nil {
		related.R = &stockR{
			StockCvterm: o,
		}
	} else {
		related.R.StockCvterm = o
	}

	return nil
}
Example #28
0
// SetUser of the stock_order to the related item.
// Sets o.R.User to related.
// Adds o to related.R.UserStockOrders.
func (o *StockOrder) SetUser(exec boil.Executor, insert bool, related *AuthUser) 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_order\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"user_id"}),
		strmangle.WhereClause("\"", "\"", 2, stockOrderPrimaryKeyColumns),
	)
	values := []interface{}{related.AuthUserID, o.StockOrderID}

	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.UserID = related.AuthUserID

	if o.R == nil {
		o.R = &stockOrderR{
			User: related,
		}
	} else {
		o.R.User = related
	}

	if related.R == nil {
		related.R = &authUserR{
			UserStockOrders: StockOrderSlice{o},
		}
	} else {
		related.R.UserStockOrders = append(related.R.UserStockOrders, o)
	}

	return nil
}
Example #29
0
// SetType of the featureprop to the related item.
// Sets o.R.Type to related.
// Adds o to related.R.TypeFeatureprop.
func (o *Featureprop) 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 \"featureprop\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"type_id"}),
		strmangle.WhereClause("\"", "\"", 2, featurepropPrimaryKeyColumns),
	)
	values := []interface{}{related.CvtermID, o.FeaturepropID}

	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 = related.CvtermID

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

	if related.R == nil {
		related.R = &cvtermR{
			TypeFeatureprop: o,
		}
	} else {
		related.R.TypeFeatureprop = o
	}

	return nil
}
Example #30
0
// SetAuthRole of the auth_user_role to the related item.
// Sets o.R.AuthRole to related.
// Adds o to related.R.AuthUserRoles.
func (o *AuthUserRole) SetAuthRole(exec boil.Executor, insert bool, related *AuthRole) 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 \"auth_user_role\" SET %s WHERE %s",
		strmangle.SetParamNames("\"", "\"", 1, []string{"auth_role_id"}),
		strmangle.WhereClause("\"", "\"", 2, authUserRolePrimaryKeyColumns),
	)
	values := []interface{}{related.AuthRoleID, o.AuthUserRoleID}

	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.AuthRoleID = related.AuthRoleID

	if o.R == nil {
		o.R = &authUserRoleR{
			AuthRole: related,
		}
	} else {
		o.R.AuthRole = related
	}

	if related.R == nil {
		related.R = &authRoleR{
			AuthUserRoles: AuthUserRoleSlice{o},
		}
	} else {
		related.R.AuthUserRoles = append(related.R.AuthUserRoles, o)
	}

	return nil
}