improve integration with record package

This commit is contained in:
2026-07-07 23:31:36 +01:00
parent f24f15a4f6
commit 6e8fdbba1e
4 changed files with 201 additions and 1 deletions
+20
View File
@@ -5,6 +5,8 @@ import (
"database/sql"
"fmt"
"strings"
"code.aneur.in/go/record"
)
// https://www.sqlite.org/lang_select.html
@@ -123,6 +125,24 @@ func (q *SelectQuery) Query() (*sql.Rows, error) {
return nil, ErrNoDatabase
}
func (q *SelectQuery) QueryRecord() (record.Record, error) {
rows, err := q.Query()
if err != nil {
return nil, err
}
return ScanOneRecord(rows)
}
func (q *SelectQuery) QueryRecords() ([]record.Record, error) {
rows, err := q.Query()
if err != nil {
return nil, err
}
return ScanRecords(rows)
}
func (q *SelectQuery) QueryRow() *sql.Row {
if q.DB != nil {
if q.Ctx != nil {