本文整理汇总了Golang中github.com/vattle/sqlboiler/strmangle.Placeholders函数的典型用法代码示例。如果您正苦于以下问题:Golang Placeholders函数的具体用法?Golang Placeholders怎么用?Golang Placeholders使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Placeholders函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ReloadAll
// ReloadAll refetches every row with matching primary key column values
// and overwrites the original object slice with the newly updated slice.
func (o *FeaturepropPubSlice) ReloadAll(exec boil.Executor) error {
if o == nil || len(*o) == 0 {
return nil
}
featurepropPubs := FeaturepropPubSlice{}
var args []interface{}
for _, obj := range *o {
pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), featurepropPubPrimaryKeyMapping)
args = append(args, pkeyArgs...)
}
sql := fmt.Sprintf(
"SELECT \"featureprop_pub\".* 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)),
)
q := queries.Raw(exec, sql, args...)
err := q.Bind(&featurepropPubs)
if err != nil {
return errors.Wrap(err, "chado: unable to reload all in FeaturepropPubSlice")
}
*o = featurepropPubs
return nil
}
示例2: ReloadAll
// ReloadAll refetches every row with matching primary key column values
// and overwrites the original object slice with the newly updated slice.
func (o *PhenotypeComparisonCvtermSlice) ReloadAll(exec boil.Executor) error {
if o == nil || len(*o) == 0 {
return nil
}
phenotypeComparisonCvterms := PhenotypeComparisonCvtermSlice{}
var args []interface{}
for _, obj := range *o {
pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), phenotypeComparisonCvtermPrimaryKeyMapping)
args = append(args, pkeyArgs...)
}
sql := fmt.Sprintf(
"SELECT \"phenotype_comparison_cvterm\".* FROM \"phenotype_comparison_cvterm\" WHERE (%s) IN (%s)",
strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, phenotypeComparisonCvtermPrimaryKeyColumns), ","),
strmangle.Placeholders(dialect.IndexPlaceholders, len(*o)*len(phenotypeComparisonCvtermPrimaryKeyColumns), 1, len(phenotypeComparisonCvtermPrimaryKeyColumns)),
)
q := queries.Raw(exec, sql, args...)
err := q.Bind(&phenotypeComparisonCvterms)
if err != nil {
return errors.Wrap(err, "chado: unable to reload all in PhenotypeComparisonCvtermSlice")
}
*o = phenotypeComparisonCvterms
return nil
}
示例3: 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
}
示例4: UpdateAll
// 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
}
示例5: Insert
// Insert a single record using an executor.
// Whitelist behavior: If a whitelist is provided, only those columns supplied are inserted
// No whitelist behavior: Without a whitelist, columns are inferred by the following rules:
// - All columns without a default value are included (i.e. name, age)
// - All columns with a default, but non-zero are included (i.e. health = 75)
func (o *FeaturepropPub) Insert(exec boil.Executor, whitelist ...string) error {
if o == nil {
return errors.New("chado: no featureprop_pub provided for insertion")
}
var err error
if err := o.doBeforeInsertHooks(exec); err != nil {
return err
}
nzDefaults := queries.NonZeroDefaultSet(featurepropPubColumnsWithDefault, o)
key := makeCacheKey(whitelist, nzDefaults)
featurepropPubInsertCacheMut.RLock()
cache, cached := featurepropPubInsertCache[key]
featurepropPubInsertCacheMut.RUnlock()
if !cached {
wl, returnColumns := strmangle.InsertColumnSet(
featurepropPubColumns,
featurepropPubColumnsWithDefault,
featurepropPubColumnsWithoutDefault,
nzDefaults,
whitelist,
)
cache.valueMapping, err = queries.BindMapping(featurepropPubType, featurepropPubMapping, wl)
if err != nil {
return err
}
cache.retMapping, err = queries.BindMapping(featurepropPubType, featurepropPubMapping, returnColumns)
if err != nil {
return err
}
cache.query = fmt.Sprintf("INSERT INTO \"featureprop_pub\" (\"%s\") VALUES (%s)", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.IndexPlaceholders, len(wl), 1, 1))
if len(cache.retMapping) != 0 {
cache.query += fmt.Sprintf(" RETURNING \"%s\"", strings.Join(returnColumns, "\",\""))
}
}
value := reflect.Indirect(reflect.ValueOf(o))
vals := queries.ValuesFromMapping(value, cache.valueMapping)
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, cache.query)
fmt.Fprintln(boil.DebugWriter, vals)
}
if len(cache.retMapping) != 0 {
err = exec.QueryRow(cache.query, vals...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...)
} else {
_, err = exec.Exec(cache.query, vals...)
}
if err != nil {
return errors.Wrap(err, "chado: unable to insert into featureprop_pub")
}
if !cached {
featurepropPubInsertCacheMut.Lock()
featurepropPubInsertCache[key] = cache
featurepropPubInsertCacheMut.Unlock()
}
return o.doAfterInsertHooks(exec)
}
示例6: LoadPub
// LoadPub allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (featurepropPubL) LoadPub(e boil.Executor, singular bool, maybeFeaturepropPub interface{}) error {
var slice []*FeaturepropPub
var object *FeaturepropPub
count := 1
if singular {
object = maybeFeaturepropPub.(*FeaturepropPub)
} else {
slice = *maybeFeaturepropPub.(*FeaturepropPubSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &featurepropPubR{}
args[0] = object.PubID
} else {
for i, obj := range slice {
obj.R = &featurepropPubR{}
args[i] = obj.PubID
}
}
query := fmt.Sprintf(
"select * from \"pub\" where \"pub_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load Pub")
}
defer results.Close()
var resultSlice []*Pub
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice Pub")
}
if len(featurepropPubAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular && len(resultSlice) != 0 {
object.R.Pub = resultSlice[0]
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.PubID == foreign.PubID {
local.R.Pub = foreign
break
}
}
}
return nil
}
示例7: LoadAuthRole
// LoadAuthRole allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (authUserRoleL) LoadAuthRole(e boil.Executor, singular bool, maybeAuthUserRole interface{}) error {
var slice []*AuthUserRole
var object *AuthUserRole
count := 1
if singular {
object = maybeAuthUserRole.(*AuthUserRole)
} else {
slice = *maybeAuthUserRole.(*AuthUserRoleSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &authUserRoleR{}
args[0] = object.AuthRoleID
} else {
for i, obj := range slice {
obj.R = &authUserRoleR{}
args[i] = obj.AuthRoleID
}
}
query := fmt.Sprintf(
"select * from \"auth_role\" where \"auth_role_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load AuthRole")
}
defer results.Close()
var resultSlice []*AuthRole
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice AuthRole")
}
if len(authUserRoleAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular && len(resultSlice) != 0 {
object.R.AuthRole = resultSlice[0]
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.AuthRoleID == foreign.AuthRoleID {
local.R.AuthRole = foreign
break
}
}
}
return nil
}
示例8: LoadDbxref
// LoadDbxref allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (cvtermDbxrefL) LoadDbxref(e boil.Executor, singular bool, maybeCvtermDbxref interface{}) error {
var slice []*CvtermDbxref
var object *CvtermDbxref
count := 1
if singular {
object = maybeCvtermDbxref.(*CvtermDbxref)
} else {
slice = *maybeCvtermDbxref.(*CvtermDbxrefSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &cvtermDbxrefR{}
args[0] = object.DbxrefID
} else {
for i, obj := range slice {
obj.R = &cvtermDbxrefR{}
args[i] = obj.DbxrefID
}
}
query := fmt.Sprintf(
"select * from \"dbxref\" where \"dbxref_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load Dbxref")
}
defer results.Close()
var resultSlice []*Dbxref
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice Dbxref")
}
if len(cvtermDbxrefAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular && len(resultSlice) != 0 {
object.R.Dbxref = resultSlice[0]
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.DbxrefID == foreign.DbxrefID {
local.R.Dbxref = foreign
break
}
}
}
return nil
}
示例9: LoadStockcollections
// LoadStockcollections allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (contactL) LoadStockcollections(e boil.Executor, singular bool, maybeContact interface{}) error {
var slice []*Contact
var object *Contact
count := 1
if singular {
object = maybeContact.(*Contact)
} else {
slice = *maybeContact.(*ContactSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &contactR{}
args[0] = object.ContactID
} else {
for i, obj := range slice {
obj.R = &contactR{}
args[i] = obj.ContactID
}
}
query := fmt.Sprintf(
"select * from \"stockcollection\" where \"contact_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load stockcollection")
}
defer results.Close()
var resultSlice []*Stockcollection
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice stockcollection")
}
if len(stockcollectionAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular {
object.R.Stockcollections = resultSlice
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.ContactID == foreign.ContactID.Int {
local.R.Stockcollections = append(local.R.Stockcollections, foreign)
break
}
}
}
return nil
}
示例10: LoadStockcollectionprop
// LoadStockcollectionprop allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (stockcollectionL) LoadStockcollectionprop(e boil.Executor, singular bool, maybeStockcollection interface{}) error {
var slice []*Stockcollection
var object *Stockcollection
count := 1
if singular {
object = maybeStockcollection.(*Stockcollection)
} else {
slice = *maybeStockcollection.(*StockcollectionSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &stockcollectionR{}
args[0] = object.StockcollectionID
} else {
for i, obj := range slice {
obj.R = &stockcollectionR{}
args[i] = obj.StockcollectionID
}
}
query := fmt.Sprintf(
"select * from \"stockcollectionprop\" where \"stockcollection_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load Stockcollectionprop")
}
defer results.Close()
var resultSlice []*Stockcollectionprop
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice Stockcollectionprop")
}
if len(stockcollectionAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular && len(resultSlice) != 0 {
object.R.Stockcollectionprop = resultSlice[0]
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.StockcollectionID == foreign.StockcollectionID {
local.R.Stockcollectionprop = foreign
break
}
}
}
return nil
}
示例11: Insert
// Insert a single record using an executor.
// Whitelist behavior: If a whitelist is provided, only those columns supplied are inserted
// No whitelist behavior: Without a whitelist, columns are inferred by the following rules:
// - All columns without a default value are included (i.e. name, age)
// - All columns with a default, but non-zero are included (i.e. health = 75)
func (o *AuthRolePermission) Insert(exec boil.Executor, whitelist ...string) error {
if o == nil {
return errors.New("chado: no auth_role_permission provided for insertion")
}
var err error
currTime := time.Now().In(boil.GetLocation())
if o.CreatedAt.Time.IsZero() {
o.CreatedAt.Time = currTime
o.CreatedAt.Valid = true
}
if o.UpdatedAt.Time.IsZero() {
o.UpdatedAt.Time = currTime
o.UpdatedAt.Valid = true
}
if err := o.doBeforeInsertHooks(exec); err != nil {
return err
}
nzDefaults := queries.NonZeroDefaultSet(authRolePermissionColumnsWithDefault, o)
key := makeCacheKey(whitelist, nzDefaults)
authRolePermissionInsertCacheMut.RLock()
cache, cached := authRolePermissionInsertCache[key]
authRolePermissionInsertCacheMut.RUnlock()
if !cached {
wl, returnColumns := strmangle.InsertColumnSet(
authRolePermissionColumns,
authRolePermissionColumnsWithDefault,
authRolePermissionColumnsWithoutDefault,
nzDefaults,
whitelist,
)
cache.valueMapping, err = queries.BindMapping(authRolePermissionType, authRolePermissionMapping, wl)
if err != nil {
return err
}
cache.retMapping, err = queries.BindMapping(authRolePermissionType, authRolePermissionMapping, returnColumns)
if err != nil {
return err
}
cache.query = fmt.Sprintf("INSERT INTO \"auth_role_permission\" (\"%s\") VALUES (%s)", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.IndexPlaceholders, len(wl), 1, 1))
if len(cache.retMapping) != 0 {
cache.query += fmt.Sprintf(" RETURNING \"%s\"", strings.Join(returnColumns, "\",\""))
}
}
value := reflect.Indirect(reflect.ValueOf(o))
vals := queries.ValuesFromMapping(value, cache.valueMapping)
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, cache.query)
fmt.Fprintln(boil.DebugWriter, vals)
}
if len(cache.retMapping) != 0 {
err = exec.QueryRow(cache.query, vals...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...)
} else {
_, err = exec.Exec(cache.query, vals...)
}
if err != nil {
return errors.Wrap(err, "chado: unable to insert into auth_role_permission")
}
if !cached {
authRolePermissionInsertCacheMut.Lock()
authRolePermissionInsertCache[key] = cache
authRolePermissionInsertCacheMut.Unlock()
}
return o.doAfterInsertHooks(exec)
}
示例12: LoadThumbnails
// LoadThumbnails allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (fileL) LoadThumbnails(e boil.Executor, singular bool, maybeFile interface{}) error {
var slice []*File
var object *File
count := 1
if singular {
object = maybeFile.(*File)
} else {
slice = *maybeFile.(*FileSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &fileR{}
args[0] = object.ID
} else {
for i, obj := range slice {
obj.R = &fileR{}
args[i] = obj.ID
}
}
query := fmt.Sprintf(
"select * from \"thumbnails\" where \"file_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load thumbnails")
}
defer results.Close()
var resultSlice []*Thumbnail
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice thumbnails")
}
if len(thumbnailAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular {
object.R.Thumbnails = resultSlice
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.ID == foreign.FileID {
local.R.Thumbnails = append(local.R.Thumbnails, foreign)
break
}
}
}
return nil
}
示例13: LoadType
// LoadType allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (pubRelationshipL) LoadType(e boil.Executor, singular bool, maybePubRelationship interface{}) error {
var slice []*PubRelationship
var object *PubRelationship
count := 1
if singular {
object = maybePubRelationship.(*PubRelationship)
} else {
slice = *maybePubRelationship.(*PubRelationshipSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &pubRelationshipR{}
args[0] = object.TypeID
} else {
for i, obj := range slice {
obj.R = &pubRelationshipR{}
args[i] = obj.TypeID
}
}
query := fmt.Sprintf(
"select * from \"cvterm\" where \"cvterm_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load Cvterm")
}
defer results.Close()
var resultSlice []*Cvterm
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice Cvterm")
}
if len(pubRelationshipAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular && len(resultSlice) != 0 {
object.R.Type = resultSlice[0]
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.TypeID == foreign.CvtermID {
local.R.Type = foreign
break
}
}
}
return nil
}
示例14: LoadEnvironment
// LoadEnvironment allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (phenstatementL) LoadEnvironment(e boil.Executor, singular bool, maybePhenstatement interface{}) error {
var slice []*Phenstatement
var object *Phenstatement
count := 1
if singular {
object = maybePhenstatement.(*Phenstatement)
} else {
slice = *maybePhenstatement.(*PhenstatementSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &phenstatementR{}
args[0] = object.EnvironmentID
} else {
for i, obj := range slice {
obj.R = &phenstatementR{}
args[i] = obj.EnvironmentID
}
}
query := fmt.Sprintf(
"select * from \"environment\" where \"environment_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load Environment")
}
defer results.Close()
var resultSlice []*Environment
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice Environment")
}
if len(phenstatementAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular && len(resultSlice) != 0 {
object.R.Environment = resultSlice[0]
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.EnvironmentID == foreign.EnvironmentID {
local.R.Environment = foreign
break
}
}
}
return nil
}
示例15: LoadJbrowseTrack
// LoadJbrowseTrack allows an eager lookup of values, cached into the
// loaded structs of the objects.
func (jbrowseOrganismL) LoadJbrowseTrack(e boil.Executor, singular bool, maybeJbrowseOrganism interface{}) error {
var slice []*JbrowseOrganism
var object *JbrowseOrganism
count := 1
if singular {
object = maybeJbrowseOrganism.(*JbrowseOrganism)
} else {
slice = *maybeJbrowseOrganism.(*JbrowseOrganismSlice)
count = len(slice)
}
args := make([]interface{}, count)
if singular {
object.R = &jbrowseOrganismR{}
args[0] = object.JbrowseOrganismID
} else {
for i, obj := range slice {
obj.R = &jbrowseOrganismR{}
args[i] = obj.JbrowseOrganismID
}
}
query := fmt.Sprintf(
"select * from \"jbrowse_track\" where \"jbrowse_organism_id\" in (%s)",
strmangle.Placeholders(dialect.IndexPlaceholders, count, 1, 1),
)
if boil.DebugMode {
fmt.Fprintf(boil.DebugWriter, "%s\n%v\n", query, args)
}
results, err := e.Query(query, args...)
if err != nil {
return errors.Wrap(err, "failed to eager load JbrowseTrack")
}
defer results.Close()
var resultSlice []*JbrowseTrack
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice JbrowseTrack")
}
if len(jbrowseOrganismAfterSelectHooks) != 0 {
for _, obj := range resultSlice {
if err := obj.doAfterSelectHooks(e); err != nil {
return err
}
}
}
if singular && len(resultSlice) != 0 {
object.R.JbrowseTrack = resultSlice[0]
return nil
}
for _, foreign := range resultSlice {
for _, local := range slice {
if local.JbrowseOrganismID == foreign.JbrowseOrganismID {
local.R.JbrowseTrack = foreign
break
}
}
}
return nil
}