Skip to content

レシーバ名と引数名がかぶってしまう #48

@PyYoshi

Description

@PyYoshi
// +db:"services"
type Service struct {
	Bool    sql.NullBool    `db:"bool"`
	Float64 sql.NullFloat64 `db:"float64"`
	Int64   sql.NullInt64   `db:"int64"`
	String  sql.NullString  `db:"string"`
}

というモデルがあると

// QueryOne Select single record
func (s ServiceDB) QueryOne(sess *sqlabble.Session, s stmt.Statement) (Service, error) {
	query, values := sess.Builder.Build(s)
	rows, err := sess.Query(query, values...)
	if err != nil {
		return Service{}, err
	}
	ms, err := a.Map(rows)
	if err != nil {
		return Service{}, err
	}
	if len(ms) == 0 {
		return Service{}, sqlabble.NewErrRecordNotFound(a.Table.Name)
	}
	if len(ms) > 1 {
		return Service{}, sqlabble.NewErrFoundMultipleRecords(a.Table.Name)
	}
	return ms[0], nil
}

などのようにレシーバ名と引数名がかぶってしまう

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions