entc/gen: remove FromRows decoding

This commit is contained in:
Ariel Mashraki
2019-12-24 10:29:40 +02:00
parent 99510a458d
commit e5c5aec9b5
26 changed files with 2 additions and 971 deletions

View File

@@ -23,24 +23,6 @@ type User struct {
Name string `json:"name,omitempty"`
}
// FromRows scans the sql response data into User.
func (u *User) FromRows(rows *sql.Rows) error {
var scanu struct {
ID uint64
Name sql.NullString
}
// the order here should be the same as in the `user.Columns`.
if err := rows.Scan(
&scanu.ID,
&scanu.Name,
); err != nil {
return err
}
u.ID = scanu.ID
u.Name = scanu.Name.String
return nil
}
// scanValues returns the types for scanning values from sql.Rows.
func (*User) scanValues() []interface{} {
return []interface{}{
@@ -116,18 +98,6 @@ func (u *User) String() string {
// Users is a parsable slice of User.
type Users []*User
// FromRows scans the sql response data into Users.
func (u *Users) FromRows(rows *sql.Rows) error {
for rows.Next() {
scanu := &User{}
if err := scanu.FromRows(rows); err != nil {
return err
}
*u = append(*u, scanu)
}
return nil
}
func (u Users) config(cfg config) {
for _i := range u {
u[_i].config = cfg