From 7bdc14a145c4b5c380921abf1db3f2c00a9c66cc Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Tue, 12 May 2026 13:11:41 +0200 Subject: change Handle to a generic interface without explicit dep on database/sql --- oblast.go | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'oblast.go') diff --git a/oblast.go b/oblast.go index ba43798..35b51e2 100644 --- a/oblast.go +++ b/oblast.go @@ -96,7 +96,6 @@ package oblast // import "go.xyrillian.de/oblast" import ( - "context" "database/sql" "database/sql/driver" "fmt" @@ -132,25 +131,6 @@ func StructTagKeyIs(key string) PlanOption { return func(opts *planOpts) { opts.StructTagKey = key } } -// Handle is an interface for functions providing direct DB access. -// It covers methods provided by both *sql.DB and *sql.Tx, thus allowing functions using it to be used both within and outside of transactions. -type Handle interface { - ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) - PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) - QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) - QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row -} - -// TODO: investigate if we can extend type Handle to cover types github.com/jackc/pgx.{Conn,Tx} -// - those have all these methods, but with different return types that act mostly in the same way -// - a significant departure is that their Prepare() works wildly differently - -// static assertion that the respective types implement the interface -var ( - _ Handle = &sql.DB{} - _ Handle = &sql.Tx{} -) - // Store is the main interface of this library. // // It holds information on how to read and write data into record type R, -- cgit v1.2.3