mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: avoid using Go keywords as variables on scan
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/161 Reviewed By: alexsn Differential Revision: D18483166 fbshipit-source-id: 7273d284232c1bf515cc84326904b580fb70a0e3
This commit is contained in:
committed by
Facebook Github Bot
parent
84fd066e2c
commit
8093ec4127
@@ -9,7 +9,7 @@ in the LICENSE file in the root directory of this source tree.
|
||||
|
||||
// FromRows scans the sql response data into {{ $.Name }}.
|
||||
func ({{ $receiver }} *{{ $.Name }}) FromRows(rows *sql.Rows) error {
|
||||
{{- $scan := print "v" $receiver }}
|
||||
{{- $scan := print "scan" $receiver }}
|
||||
var {{ $scan }} struct {
|
||||
ID {{ if $.ID.IsString }}int{{ else }}{{ $.ID.Type }}{{ end }}
|
||||
{{ range $_, $f := $.Fields }}
|
||||
@@ -53,7 +53,7 @@ func ({{ $receiver }} *{{ $.Name }}) FromRows(rows *sql.Rows) error {
|
||||
// FromRows scans the sql response data into {{ $slice }}.
|
||||
func ({{ $receiver }} *{{ $slice }}) FromRows(rows *sql.Rows) error {
|
||||
for rows.Next() {
|
||||
{{- $scan := print "v" $receiver }}
|
||||
{{- $scan := print "scan" $receiver }}
|
||||
{{ $scan }} := &{{ $.Name }}{}
|
||||
if err := {{ $scan }}.FromRows(rows); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user