diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-07-31 21:39:56 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-07-31 23:35:23 +0200 |
| commit | 656e5dcce132716b39005814407224f989aa8c2d (patch) | |
| tree | ab0a6d3a046170f0ace6a6e4ab3668ce0af811ae /handle | |
| parent | a2f8d7a68f324d5b4086148571f990409425e22a (diff) | |
| download | go-oblast-656e5dcce132716b39005814407224f989aa8c2d.tar.gz | |
replace types Handle, DB, Conn, Tx with their gg/gsql equivalents
Diffstat (limited to 'handle')
| -rw-r--r-- | handle/handle.go | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/handle/handle.go b/handle/handle.go deleted file mode 100644 index f6e1694..0000000 --- a/handle/handle.go +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-FileCopyrightText: 2026 Stefan Majewsky <majewsky@gmx.net> -// SPDX-License-Identifier: Apache-2.0 - -// Package handle contains type definitions for connecting non-std database drivers to Oblast. -// Since most database drivers use the standard interface from database/sql, the Wrap() function from the main package covers the needs of most users. -package handle - -import ( - "context" - "database/sql" -) - -// Handle contains behavior that database handles must offer to Oblast. -// The standard-library types [*sql.DB], [*sql.Conn] and [*sql.Tx] can satisfy this interface through the respective types of the same name from the main Oblast package. -// Custom implementations of this interface can be used to connect non-std database drivers to Oblast. -// -// The method names are deliberately clunky to avoid name clashes with well-known methods like [sql.DB.Prepare] or [sql.DB.Query]. -type Handle interface { - // OblastPrepare prepares to execute a certain SQL query one or multiple times. - // - // The "repeated" flag is a hint to the implementation whether the same statement is going to be run many times. - // If false, the implementation shall choose to forego the additional effort of a full statement preparation if possible, - // and execute one-off queries instead. - OblastPrepare(ctx context.Context, query string, repeated bool) (Statement, error) - - // OblastQuery works like db.QueryContext(ctx, query, args...). - OblastQuery(ctx context.Context, query string, args []any) (Rows, error) -} - -// Statement represents a prepared statement returned from the OblastPrepare() method of [Handle]. -// The Exec and QueryRow methods shall work similarly to the respective functions on [*sql.Tx], as indicated in the comments. -// -// You will not need to interact with this type except when implementing your own [Handle]. -type Statement interface { - Close() error - - // Exec works like stmt.ExecContext(ctx, args...). - Exec(ctx context.Context, args []any) (sql.Result, error) - - // QueryRow works like stmt.QueryRow(ctx, args...).Scan(slots...). - QueryRow(ctx context.Context, args []any, slots []any) error -} - -// Rows represents a set of rows returned from the OblastQuery() method of [Handle]. -// All methods shall behave like on the [*sql.Rows] type from std. -// -// You will not need to interact with this type except when implementing your own [Handle]. -type Rows interface { - Columns() ([]string, error) - Close() error - Err() error - Next() bool - Scan(slots ...any) error -} |
