mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: remove FromRows decoding
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user