summaryrefslogtreecommitdiff
path: root/handle/handle.go
diff options
context:
space:
mode:
Diffstat (limited to 'handle/handle.go')
-rw-r--r--handle/handle.go54
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
-}