Skip to content

Commit

Permalink
Add section about manual rows iteration to dbscan doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgysavva committed Jun 29, 2020
1 parent 46dfef3 commit f9aa9a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,10 @@ Rows processing
ScanAll and ScanOne functions take care of rows processing,
they iterate rows to the end and close them after that.
Client code doesn't need to bother with that, it just passes rows to dbscan.
Manual rows iteration
It's possible to manually control rows iteration, but still use all scanning features of dbscan,
see RowScanner for details.
*/
package dbscan
8 changes: 5 additions & 3 deletions pgxscan/pgxscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,27 @@ func QueryOne(ctx context.Context, dst interface{}, q Querier, query string, arg
}

// ScanAll is a wrapper around the dbscan.ScanAll function.
// Se dbscan.ScanAll for details.
// See dbscan.ScanAll for details.
func ScanAll(dst interface{}, rows pgx.Rows) error {
err := dbscan.ScanAll(dst, NewRowsAdapter(rows))
return errors.Wrap(err, "pgxscan: proxy call to dbscan.ScanAll")
}

// ScanOne is a wrapper around the dbscan.ScanOne function.
// Se dbscan.ScanOne for details.
// See dbscan.ScanOne for details.
func ScanOne(dst interface{}, rows pgx.Rows) error {
err := dbscan.ScanOne(dst, NewRowsAdapter(rows))
return errors.Wrap(err, "pgxscan: proxy call to dbscan.ScanOne")
}

// NotFound is a wrapper around the dbscan.NotFound function.
// Se dbscan.NotFound for details.
// See dbscan.NotFound for details.
func NotFound(err error) bool {
return dbscan.NotFound(err)
}

// RowScanner is a wrapper around the dbscan.RowScanner type.
// See dbscan.RowScanner for details.
type RowScanner struct {
*dbscan.RowScanner
}
Expand All @@ -77,6 +78,7 @@ func NewRowScanner(rows pgx.Rows) *RowScanner {

// Scan is a wrapper around the dbscan.RowScanner.Scan method.
// See dbscan.RowScanner.Scan for details.
// See RowScanner for example.
func (rs *RowScanner) Scan(dst interface{}) error {
err := rs.RowScanner.Scan(dst)
return errors.Wrap(err, "pgxscan: proxy call to dbscan.RowScanner.Scan")
Expand Down
8 changes: 5 additions & 3 deletions sqlscan/sqlscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,27 @@ func QueryOne(ctx context.Context, dst interface{}, q Querier, query string, arg
}

// ScanAll is a wrapper around the dbscan.ScanAll function.
// Se dbscan.ScanAll for details.
// See dbscan.ScanAll for details.
func ScanAll(dst interface{}, rows *sql.Rows) error {
err := dbscan.ScanAll(dst, rows)
return errors.Wrap(err, "sqlscan: proxy call to dbscan.ScanAll")
}

// ScanOne is a wrapper around the dbscan.ScanOne function.
// Se dbscan.ScanOne for details.
// See dbscan.ScanOne for details.
func ScanOne(dst interface{}, rows *sql.Rows) error {
err := dbscan.ScanOne(dst, rows)
return errors.Wrap(err, "sqlscan: proxy call to dbscan.ScanOne")
}

// NotFound is a wrapper around the dbscan.NotFound function.
// Se dbscan.NotFound for details.
// See dbscan.NotFound for details.
func NotFound(err error) bool {
return dbscan.NotFound(err)
}

// RowScanner is a wrapper around the dbscan.RowScanner type.
// See dbscan.RowScanner for details.
type RowScanner struct {
*dbscan.RowScanner
}
Expand All @@ -75,6 +76,7 @@ func NewRowScanner(rows *sql.Rows) *RowScanner {

// Scan is a wrapper around the dbscan.RowScanner.Scan method.
// See dbscan.RowScanner.Scan for details.
// See RowScanner for example.
func (rs *RowScanner) Scan(dst interface{}) error {
err := rs.RowScanner.Scan(dst)
return errors.Wrap(err, "sqlscan: proxy call to dbscan.RowScanner.Scan")
Expand Down

0 comments on commit f9aa9a7

Please sign in to comment.