Documentation
¶
Index ¶
- Variables
- func New(ctx context.Context, queryWriter io.Writer, rowsProvider RowsProvider) sqldb.Connection
- type OneTimeRowsProvider
- func (p *OneTimeRowsProvider) AddRowScannerQuery(scanner sqldb.RowScanner, query string, args ...any)
- func (p *OneTimeRowsProvider) AddRowsScannerQuery(scanner sqldb.RowsScanner, query string, args ...any)
- func (p *OneTimeRowsProvider) QueryRow(structFieldNamer sqldb.StructFieldMapper, query string, args ...any) sqldb.RowScanner
- func (p *OneTimeRowsProvider) QueryRows(structFieldNamer sqldb.StructFieldMapper, query string, args ...any) sqldb.RowsScanner
- type Row
- type Rows
- type RowsProvider
Constants ¶
This section is empty.
Variables ¶
var DefaultArgFmt = "$%d"
var ErrMockedScan = errors.New("mocked scan")
Functions ¶
Types ¶
type OneTimeRowsProvider ¶
type OneTimeRowsProvider struct {
// contains filtered or unexported fields
}
func NewOneTimeRowsProvider ¶
func NewOneTimeRowsProvider() *OneTimeRowsProvider
func (*OneTimeRowsProvider) AddRowScannerQuery ¶
func (p *OneTimeRowsProvider) AddRowScannerQuery(scanner sqldb.RowScanner, query string, args ...any)
func (*OneTimeRowsProvider) AddRowsScannerQuery ¶
func (p *OneTimeRowsProvider) AddRowsScannerQuery(scanner sqldb.RowsScanner, query string, args ...any)
func (*OneTimeRowsProvider) QueryRow ¶
func (p *OneTimeRowsProvider) QueryRow(structFieldNamer sqldb.StructFieldMapper, query string, args ...any) sqldb.RowScanner
func (*OneTimeRowsProvider) QueryRows ¶
func (p *OneTimeRowsProvider) QueryRows(structFieldNamer sqldb.StructFieldMapper, query string, args ...any) sqldb.RowsScanner
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row implements impl.Row with the fields of a struct as column values.
func (*Row) StructFieldMapper ¶
func (r *Row) StructFieldMapper() sqldb.StructFieldMapper
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
func NewRowsFromStructs ¶
func NewRowsFromStructs(rowStructs any, columnNamer sqldb.StructFieldMapper) *Rows
func (*Rows) Close ¶
Close closes the Rows, preventing further enumeration. If Next is called and returns false and there are no further result sets, the Rows are closed automatically and it will suffice to check the result of Err. Close is idempotent and does not affect the result of Err.
func (*Rows) Err ¶
Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.
func (*Rows) Next ¶
Next prepares the next result row for reading with the Scan method. It returns true on success, or false if there is no next result row or an error happened while preparing it. Err should be consulted to distinguish between the two cases.
Every call to Scan, even the first one, must be preceded by a call to Next.
type RowsProvider ¶
type RowsProvider interface { QueryRow(structFieldNamer sqldb.StructFieldMapper, query string, args ...any) sqldb.RowScanner QueryRows(structFieldNamer sqldb.StructFieldMapper, query string, args ...any) sqldb.RowsScanner }
func NewSingleRowProvider ¶
func NewSingleRowProvider(row *Row) RowsProvider
NewSingleRowProvider a RowsProvider implementation with a single row that will be re-used for every query.