dialect/sql: wraps the sql.Rows with ColumnScanner interface

This commit is contained in:
Ariel Mashraki
2021-09-29 21:16:26 +03:00
committed by Ariel Mashraki
parent 123930c362
commit 899e9f0e50
2 changed files with 13 additions and 10 deletions

View File

@@ -132,7 +132,7 @@ var _ dialect.Driver = (*Driver)(nil)
type (
// Rows wraps the sql.Rows to avoid locks copy.
Rows struct{ *sql.Rows }
Rows struct{ ColumnScanner }
// Result is an alias to sql.Result.
Result = sql.Result
// NullBool is an alias to sql.NullBool.
@@ -165,3 +165,15 @@ func (n *NullScanner) Scan(value interface{}) error {
}
return nil
}
// ColumnScanner is the interface that wraps the standard
// sql.Rows methods used for scanning database rows.
type ColumnScanner interface {
Close() error
ColumnTypes() ([]*sql.ColumnType, error)
Columns() ([]string, error)
Err() error
Next() bool
NextResultSet() bool
Scan(dest ...interface{}) error
}