fix: checks for error after rows.Next call (#480)

This commit is contained in:
Ciaran Liedeman
2020-05-09 15:23:47 +02:00
committed by GitHub
parent 7f260c3ae0
commit f59abad425
5 changed files with 35 additions and 4 deletions

View File

@@ -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
}