adapter

package
v0.0.0-...-666727d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithSqlDo

func ContextWithSqlDo(ctx context.Context, db SqlDo) context.Context

func Register

func Register(a Adapter, aliases ...string)

Types

type Adapter

type Adapter interface {
	DB
	DriverName() string
	Dialect() Dialect
	Catalog(ctx context.Context) (*sqlbuilder.Tables, error)
}

func Open

func Open(ctx context.Context, dsn string) (a Adapter, err error)

type Connector

type Connector interface {
	Open(ctx context.Context, dsn *url.URL) (Adapter, error)
}

type DB

type DB interface {
	Exec(ctx context.Context, expr sqlfrag.Fragment) (sql.Result, error)
	Query(ctx context.Context, expr sqlfrag.Fragment) (*sql.Rows, error)
	Transaction(ctx context.Context, action func(ctx context.Context) error) error
	Close() error
}

func Wrap

func Wrap(d *sql.DB, convertErr func(err error) error) DB

type Dialect

type Dialect interface {
	CreateTableIsNotExists(t sqlbuilder.Table) []sqlfrag.Fragment
	DropTable(t sqlbuilder.Table) sqlfrag.Fragment
	TruncateTable(t sqlbuilder.Table) sqlfrag.Fragment

	AddColumn(col sqlbuilder.Column) sqlfrag.Fragment
	RenameColumn(col sqlbuilder.Column, target sqlbuilder.Column) sqlfrag.Fragment
	ModifyColumn(col sqlbuilder.Column, prev sqlbuilder.Column) sqlfrag.Fragment
	DropColumn(col sqlbuilder.Column) sqlfrag.Fragment

	AddIndex(key sqlbuilder.Key) sqlfrag.Fragment
	DropIndex(key sqlbuilder.Key) sqlfrag.Fragment

	DataType(columnDef sqlbuilder.ColumnDef) sqlfrag.Fragment
}

type SqlDo

type SqlDo interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
}

func SqlDoFromContext

func SqlDoFromContext(ctx context.Context) SqlDo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL