-
Christophe de Vienne authoredChristophe de Vienne authored
sql_row.go 937 B
package database
import (
"database/sql"
"github.com/jmoiron/sqlx"
)
type Row struct {
*sqlx.Row
err error
}
// Scan is a fixed implementation of sql.Row.Scan, which does not discard the
// underlying error from the internal rows object if it exists.
func (r *Row) Scan(dest ...interface{}) error {
if r.err != nil {
return r.err
}
return r.Row.Scan(dest...)
}
// Columns returns the underlying sql.Rows.Columns(), or the deferred error usually
// returned by Row.Scan().
func (r *Row) Columns() ([]string, error) {
if r.err != nil {
return []string{}, r.err
}
return r.Row.Columns()
}
// ColumnTypes returns the underlying sql.Rows.ColumnTypes(), or the deferred error.
func (r *Row) ColumnTypes() ([]*sql.ColumnType, error) {
if r.err != nil {
return []*sql.ColumnType{}, r.err
}
return r.Row.ColumnTypes()
}
// Err returns the error encountered while scanning.
func (r *Row) Err() error {
return r.err
}