dialect/sqlscan: add ScanInt64 to be used by sqlgraph

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/213

Reviewed By: alexsn

Differential Revision: D18763694

fbshipit-source-id: 890b35fcc2a28914b276ce65477788b4ddaeebf9
This commit is contained in:
Ariel Mashraki
2019-12-03 01:43:34 -08:00
committed by Facebook Github Bot
parent a4fac2db3b
commit a5e4a9cf54
4 changed files with 86 additions and 40 deletions

View File

@@ -423,12 +423,9 @@ func exist(ctx context.Context, tx dialect.Tx, query string, args ...interface{}
return false, fmt.Errorf("reading schema information %v", err)
}
defer rows.Close()
if !rows.Next() {
return false, fmt.Errorf("no rows returned")
}
var n int
if err := rows.Scan(&n); err != nil {
return false, fmt.Errorf("scanning count")
n, err := sql.ScanInt(rows)
if err != nil {
return false, err
}
return n > 0, nil
}