mirror of
https://github.com/ent/ent.git
synced 2026-05-04 08:30:57 +03:00
fix: checks for error after rows.Next call (#480)
This commit is contained in:
@@ -29,6 +29,9 @@ func (d *Postgres) init(ctx context.Context, tx dialect.Tx) error {
|
||||
}
|
||||
defer rows.Close()
|
||||
if !rows.Next() {
|
||||
if rows.Err() != nil {
|
||||
return rows.Err()
|
||||
}
|
||||
return fmt.Errorf("server_version_num variable was not found")
|
||||
}
|
||||
var version string
|
||||
@@ -93,6 +96,9 @@ func (d *Postgres) table(ctx context.Context, tx dialect.Tx, name string) (*Tabl
|
||||
}
|
||||
t.AddColumn(c)
|
||||
}
|
||||
if rows.Err() != nil {
|
||||
return nil, rows.Err()
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, fmt.Errorf("closing rows %v", err)
|
||||
}
|
||||
@@ -184,6 +190,9 @@ func (d *Postgres) indexes(ctx context.Context, tx dialect.Tx, table string) (In
|
||||
}
|
||||
idx.columns = append(idx.columns, column)
|
||||
}
|
||||
if rows.Err() != nil {
|
||||
return nil, rows.Err()
|
||||
}
|
||||
return idxs, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user