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

@@ -10,7 +10,6 @@ import (
"fmt"
"strings"
"github.com/facebookincubator/ent/dialect/sql"
"github.com/facebookincubator/ent/entc/integration/customid/ent/blob"
"github.com/google/uuid"
)
@@ -24,24 +23,6 @@ type Blob struct {
UUID uuid.UUID `json:"uuid,omitempty"`
}
// FromRows scans the sql response data into Blob.
func (b *Blob) FromRows(rows *sql.Rows) error {
var scanb struct {
ID uuid.UUID
UUID uuid.UUID
}
// the order here should be the same as in the `blob.Columns`.
if err := rows.Scan(
&scanb.ID,
&scanb.UUID,
); err != nil {
return err
}
b.ID = scanb.ID
b.UUID = scanb.UUID
return nil
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Blob) scanValues() []interface{} {
return []interface{}{
@@ -102,18 +83,6 @@ func (b *Blob) String() string {
// Blobs is a parsable slice of Blob.
type Blobs []*Blob
// FromRows scans the sql response data into Blobs.
func (b *Blobs) FromRows(rows *sql.Rows) error {
for rows.Next() {
scanb := &Blob{}
if err := scanb.FromRows(rows); err != nil {
return err
}
*b = append(*b, scanb)
}
return nil
}
func (b Blobs) config(cfg config) {
for _i := range b {
b[_i].config = cfg

View File

@@ -21,21 +21,6 @@ type Group struct {
ID int `json:"id,omitempty"`
}
// FromRows scans the sql response data into Group.
func (gr *Group) FromRows(rows *sql.Rows) error {
var scangr struct {
ID int
}
// the order here should be the same as in the `group.Columns`.
if err := rows.Scan(
&scangr.ID,
); err != nil {
return err
}
gr.ID = scangr.ID
return nil
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Group) scanValues() []interface{} {
return []interface{}{
@@ -93,18 +78,6 @@ func (gr *Group) String() string {
// Groups is a parsable slice of Group.
type Groups []*Group
// FromRows scans the sql response data into Groups.
func (gr *Groups) FromRows(rows *sql.Rows) error {
for rows.Next() {
scangr := &Group{}
if err := scangr.FromRows(rows); err != nil {
return err
}
*gr = append(*gr, scangr)
}
return nil
}
func (gr Groups) config(cfg config) {
for _i := range gr {
gr[_i].config = cfg

View File

@@ -21,21 +21,6 @@ type User struct {
ID int `json:"id,omitempty"`
}
// FromRows scans the sql response data into User.
func (u *User) FromRows(rows *sql.Rows) error {
var scanu struct {
ID int
}
// the order here should be the same as in the `user.Columns`.
if err := rows.Scan(
&scanu.ID,
); err != nil {
return err
}
u.ID = scanu.ID
return nil
}
// scanValues returns the types for scanning values from sql.Rows.
func (*User) scanValues() []interface{} {
return []interface{}{
@@ -93,18 +78,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