Fix API inconsistency.

This commit is contained in:
Nuno Cruces
2024-07-26 12:25:15 +01:00
parent 32d998c84b
commit 73125945f8
10 changed files with 11 additions and 11 deletions

View File

@@ -62,7 +62,7 @@ func (c *cursor) RowID() (int64, error) {
return int64(c.rowID), nil return int64(c.rowID), nil
} }
func (c *cursor) Column(ctx *sqlite3.Context, n int) error { func (c *cursor) Column(ctx sqlite3.Context, n int) error {
if n != 0 { if n != 0 {
return nil return nil
} }

View File

@@ -120,7 +120,7 @@ func Test_cursor_Column(t *testing.T) {
want = want[1:] want = want[1:]
} }
if err := rows.Err(); err != nil { if err := rows.Err(); err != nil {
log.Fatal(err) t.Fatal(err)
} }
} }

View File

@@ -307,7 +307,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
return nil return nil
} }
func (c *cursor) Column(ctx *sqlite3.Context, n int) error { func (c *cursor) Column(ctx sqlite3.Context, n int) error {
if ctx.VTabNoChange() { if ctx.VTabNoChange() {
return nil return nil
} }

View File

@@ -239,7 +239,7 @@ func (c *cursor) RowID() (int64, error) {
return c.rowID, nil return c.rowID, nil
} }
func (c *cursor) Column(ctx *sqlite3.Context, col int) error { func (c *cursor) Column(ctx sqlite3.Context, col int) error {
if col < len(c.row) { if col < len(c.row) {
typ := text typ := text
if col < len(c.table.typs) { if col < len(c.table.typs) {

View File

@@ -114,7 +114,7 @@ func (c *cursor) RowID() (int64, error) {
return c.rowID, nil return c.rowID, nil
} }
func (c *cursor) Column(ctx *sqlite3.Context, n int) error { func (c *cursor) Column(ctx sqlite3.Context, n int) error {
switch n { switch n {
case 0: // name case 0: // name
name := strings.TrimPrefix(c.curr.path, c.base) name := strings.TrimPrefix(c.curr.path, c.base)

View File

@@ -91,7 +91,7 @@ func (c *cursor) RowID() (int64, error) {
return c.rowID, nil return c.rowID, nil
} }
func (c *cursor) Column(ctx *sqlite3.Context, n int) error { func (c *cursor) Column(ctx sqlite3.Context, n int) error {
if n == 0 { if n == 0 {
ctx.ResultRawText(c.line) ctx.ResultRawText(c.line)
} }

View File

@@ -225,7 +225,7 @@ func (c *cursor) RowID() (int64, error) {
return c.rowID, nil return c.rowID, nil
} }
func (c *cursor) Column(ctx *sqlite3.Context, col int) error { func (c *cursor) Column(ctx sqlite3.Context, col int) error {
count := c.scan.ColumnCount() count := c.scan.ColumnCount()
if col < count { if col < count {
ctx.ResultValue(c.scan.ColumnValue(col)) ctx.ResultValue(c.scan.ColumnValue(col))

View File

@@ -201,7 +201,7 @@ func (c *cursor) RowID() (int64, error) {
return c.rowID, nil return c.rowID, nil
} }
func (c *cursor) Column(ctx *sqlite3.Context, col int) error { func (c *cursor) Column(ctx sqlite3.Context, col int) error {
switch outputs := c.stmt.ColumnCount(); { switch outputs := c.stmt.ColumnCount(); {
case col < outputs: case col < outputs:
ctx.ResultValue(c.stmt.ColumnValue(col)) ctx.ResultValue(c.stmt.ColumnValue(col))

View File

@@ -247,7 +247,7 @@ type VTabCursor interface {
// https://sqlite.org/vtab.html#xeof // https://sqlite.org/vtab.html#xeof
EOF() bool EOF() bool
// https://sqlite.org/vtab.html#xcolumn // https://sqlite.org/vtab.html#xcolumn
Column(ctx *Context, n int) error Column(ctx Context, n int) error
// https://sqlite.org/vtab.html#xrowid // https://sqlite.org/vtab.html#xrowid
RowID() (int64, error) RowID() (int64, error)
} }
@@ -618,7 +618,7 @@ func cursorNextCallback(ctx context.Context, mod api.Module, pCur uint32) uint32
func cursorColumnCallback(ctx context.Context, mod api.Module, pCur, pCtx uint32, n int32) uint32 { func cursorColumnCallback(ctx context.Context, mod api.Module, pCur, pCtx uint32, n int32) uint32 {
cursor := vtabGetHandle(ctx, mod, pCur).(VTabCursor) cursor := vtabGetHandle(ctx, mod, pCur).(VTabCursor)
db := ctx.Value(connKey{}).(*Conn) db := ctx.Value(connKey{}).(*Conn)
err := cursor.Column(&Context{db, pCtx}, int(n)) err := cursor.Column(Context{db, pCtx}, int(n))
return vtabError(ctx, mod, pCur, _CURSOR_ERROR, err) return vtabError(ctx, mod, pCur, _CURSOR_ERROR, err)
} }

View File

@@ -92,7 +92,7 @@ func (cur *seriesCursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value)
return nil return nil
} }
func (cur *seriesCursor) Column(ctx *sqlite3.Context, col int) error { func (cur *seriesCursor) Column(ctx sqlite3.Context, col int) error {
switch col { switch col {
case 0: case 0:
ctx.ResultInt64(cur.value) ctx.ResultInt64(cur.value)