本文整理汇总了Golang中github.com/vattle/sqlboiler/boil.Executor.QueryRow方法的典型用法代码示例。如果您正苦于以下问题:Golang Executor.QueryRow方法的具体用法?Golang Executor.QueryRow怎么用?Golang Executor.QueryRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vattle/sqlboiler/boil.Executor
的用法示例。
在下文中一共展示了Executor.QueryRow方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TableinfoExists
// TableinfoExists checks if the Tableinfo row exists.
func TableinfoExists(exec boil.Executor, tableinfoID int) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"tableinfo\" where \"tableinfo_id\"=$1 limit 1)"
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, sql)
fmt.Fprintln(boil.DebugWriter, tableinfoID)
}
row := exec.QueryRow(sql, tableinfoID)
err := row.Scan(&exists)
if err != nil {
return false, errors.Wrap(err, "chado: unable to check if tableinfo exists")
}
return exists, nil
}
示例2: FeaturepropPubExists
// FeaturepropPubExists checks if the FeaturepropPub row exists.
func FeaturepropPubExists(exec boil.Executor, featurepropPubID int) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"featureprop_pub\" where \"featureprop_pub_id\"=$1 limit 1)"
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, sql)
fmt.Fprintln(boil.DebugWriter, featurepropPubID)
}
row := exec.QueryRow(sql, featurepropPubID)
err := row.Scan(&exists)
if err != nil {
return false, errors.Wrap(err, "chado: unable to check if featureprop_pub exists")
}
return exists, nil
}
示例3: StockRelationshipCvtermExists
// StockRelationshipCvtermExists checks if the StockRelationshipCvterm row exists.
func StockRelationshipCvtermExists(exec boil.Executor, stockRelationshipCvtermID int) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"stock_relationship_cvterm\" where \"stock_relationship_cvterm_id\"=$1 limit 1)"
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, sql)
fmt.Fprintln(boil.DebugWriter, stockRelationshipCvtermID)
}
row := exec.QueryRow(sql, stockRelationshipCvtermID)
err := row.Scan(&exists)
if err != nil {
return false, errors.Wrap(err, "chado: unable to check if stock_relationship_cvterm exists")
}
return exists, nil
}
示例4: AuthUserRoleExists
// AuthUserRoleExists checks if the AuthUserRole row exists.
func AuthUserRoleExists(exec boil.Executor, authUserRoleID int) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"auth_user_role\" where \"auth_user_role_id\"=$1 limit 1)"
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, sql)
fmt.Fprintln(boil.DebugWriter, authUserRoleID)
}
row := exec.QueryRow(sql, authUserRoleID)
err := row.Scan(&exists)
if err != nil {
return false, errors.Wrap(err, "chado: unable to check if auth_user_role exists")
}
return exists, nil
}
示例5: FileExists
// FileExists checks if the File row exists.
func FileExists(exec boil.Executor, id string) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"files\" where \"id\"=$1 limit 1)"
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, sql)
fmt.Fprintln(boil.DebugWriter, id)
}
row := exec.QueryRow(sql, id)
err := row.Scan(&exists)
if err != nil {
return false, errors.Wrap(err, "models: unable to check if files exists")
}
return exists, nil
}
示例6: JbrowseOrganismExists
// JbrowseOrganismExists checks if the JbrowseOrganism row exists.
func JbrowseOrganismExists(exec boil.Executor, jbrowseOrganismID int) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"jbrowse_organism\" where \"jbrowse_organism_id\"=$1 limit 1)"
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, sql)
fmt.Fprintln(boil.DebugWriter, jbrowseOrganismID)
}
row := exec.QueryRow(sql, jbrowseOrganismID)
err := row.Scan(&exists)
if err != nil {
return false, errors.Wrap(err, "chado: unable to check if jbrowse_organism exists")
}
return exists, nil
}
示例7: PhenotypeComparisonCvtermExists
// PhenotypeComparisonCvtermExists checks if the PhenotypeComparisonCvterm row exists.
func PhenotypeComparisonCvtermExists(exec boil.Executor, phenotypeComparisonCvtermID int) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"phenotype_comparison_cvterm\" where \"phenotype_comparison_cvterm_id\"=$1 limit 1)"
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, sql)
fmt.Fprintln(boil.DebugWriter, phenotypeComparisonCvtermID)
}
row := exec.QueryRow(sql, phenotypeComparisonCvtermID)
err := row.Scan(&exists)
if err != nil {
return false, errors.Wrap(err, "chado: unable to check if phenotype_comparison_cvterm exists")
}
return exists, nil
}
示例8: Upsert
// Upsert attempts an insert using an executor, and does an update or ignore on conflict.
func (o *FeaturepropPub) Upsert(exec boil.Executor, updateOnConflict bool, conflictColumns []string, updateColumns []string, whitelist ...string) error {
if o == nil {
return errors.New("chado: no featureprop_pub provided for upsert")
}
if err := o.doBeforeUpsertHooks(exec); err != nil {
return err
}
nzDefaults := queries.NonZeroDefaultSet(featurepropPubColumnsWithDefault, o)
// Build cache key in-line uglily - mysql vs postgres problems
buf := strmangle.GetBuffer()
if updateOnConflict {
buf.WriteByte('t')
} else {
buf.WriteByte('f')
}
buf.WriteByte('.')
for _, c := range conflictColumns {
buf.WriteString(c)
}
buf.WriteByte('.')
for _, c := range updateColumns {
buf.WriteString(c)
}
buf.WriteByte('.')
for _, c := range whitelist {
buf.WriteString(c)
}
buf.WriteByte('.')
for _, c := range nzDefaults {
buf.WriteString(c)
}
key := buf.String()
strmangle.PutBuffer(buf)
featurepropPubUpsertCacheMut.RLock()
cache, cached := featurepropPubUpsertCache[key]
featurepropPubUpsertCacheMut.RUnlock()
var err error
if !cached {
var ret []string
whitelist, ret = strmangle.InsertColumnSet(
featurepropPubColumns,
featurepropPubColumnsWithDefault,
featurepropPubColumnsWithoutDefault,
nzDefaults,
whitelist,
)
update := strmangle.UpdateColumnSet(
featurepropPubColumns,
featurepropPubPrimaryKeyColumns,
updateColumns,
)
if len(update) == 0 {
return errors.New("chado: unable to upsert featureprop_pub, could not build update column list")
}
conflict := conflictColumns
if len(conflict) == 0 {
conflict = make([]string, len(featurepropPubPrimaryKeyColumns))
copy(conflict, featurepropPubPrimaryKeyColumns)
}
cache.query = queries.BuildUpsertQueryPostgres(dialect, "\"featureprop_pub\"", updateOnConflict, ret, update, conflict, whitelist)
cache.valueMapping, err = queries.BindMapping(featurepropPubType, featurepropPubMapping, whitelist)
if err != nil {
return err
}
if len(ret) != 0 {
cache.retMapping, err = queries.BindMapping(featurepropPubType, featurepropPubMapping, ret)
if err != nil {
return err
}
}
}
value := reflect.Indirect(reflect.ValueOf(o))
vals := queries.ValuesFromMapping(value, cache.valueMapping)
var returns []interface{}
if len(cache.retMapping) != 0 {
returns = queries.PtrsFromMapping(value, cache.retMapping)
}
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, cache.query)
fmt.Fprintln(boil.DebugWriter, vals)
}
if len(cache.retMapping) != 0 {
err = exec.QueryRow(cache.query, vals...).Scan(returns...)
} else {
_, err = exec.Exec(cache.query, vals...)
}
if err != nil {
return errors.Wrap(err, "chado: unable to upsert for featureprop_pub")
//.........这里部分代码省略.........
示例9: 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)
}
示例10: Upsert
//.........这里部分代码省略.........
nzDefaults := queries.NonZeroDefaultSet(authRolePermissionColumnsWithDefault, o)
// Build cache key in-line uglily - mysql vs postgres problems
buf := strmangle.GetBuffer()
if updateOnConflict {
buf.WriteByte('t')
} else {
buf.WriteByte('f')
}
buf.WriteByte('.')
for _, c := range conflictColumns {
buf.WriteString(c)
}
buf.WriteByte('.')
for _, c := range updateColumns {
buf.WriteString(c)
}
buf.WriteByte('.')
for _, c := range whitelist {
buf.WriteString(c)
}
buf.WriteByte('.')
for _, c := range nzDefaults {
buf.WriteString(c)
}
key := buf.String()
strmangle.PutBuffer(buf)
authRolePermissionUpsertCacheMut.RLock()
cache, cached := authRolePermissionUpsertCache[key]
authRolePermissionUpsertCacheMut.RUnlock()
var err error
if !cached {
var ret []string
whitelist, ret = strmangle.InsertColumnSet(
authRolePermissionColumns,
authRolePermissionColumnsWithDefault,
authRolePermissionColumnsWithoutDefault,
nzDefaults,
whitelist,
)
update := strmangle.UpdateColumnSet(
authRolePermissionColumns,
authRolePermissionPrimaryKeyColumns,
updateColumns,
)
if len(update) == 0 {
return errors.New("chado: unable to upsert auth_role_permission, could not build update column list")
}
conflict := conflictColumns
if len(conflict) == 0 {
conflict = make([]string, len(authRolePermissionPrimaryKeyColumns))
copy(conflict, authRolePermissionPrimaryKeyColumns)
}
cache.query = queries.BuildUpsertQueryPostgres(dialect, "\"auth_role_permission\"", updateOnConflict, ret, update, conflict, whitelist)
cache.valueMapping, err = queries.BindMapping(authRolePermissionType, authRolePermissionMapping, whitelist)
if err != nil {
return err
}
if len(ret) != 0 {
cache.retMapping, err = queries.BindMapping(authRolePermissionType, authRolePermissionMapping, ret)
if err != nil {
return err
}
}
}
value := reflect.Indirect(reflect.ValueOf(o))
vals := queries.ValuesFromMapping(value, cache.valueMapping)
var returns []interface{}
if len(cache.retMapping) != 0 {
returns = queries.PtrsFromMapping(value, cache.retMapping)
}
if boil.DebugMode {
fmt.Fprintln(boil.DebugWriter, cache.query)
fmt.Fprintln(boil.DebugWriter, vals)
}
if len(cache.retMapping) != 0 {
err = exec.QueryRow(cache.query, vals...).Scan(returns...)
} else {
_, err = exec.Exec(cache.query, vals...)
}
if err != nil {
return errors.Wrap(err, "chado: unable to upsert for auth_role_permission")
}
if !cached {
authRolePermissionUpsertCacheMut.Lock()
authRolePermissionUpsertCache[key] = cache
authRolePermissionUpsertCacheMut.Unlock()
}
return o.doAfterUpsertHooks(exec)
}
示例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)
}