adaptor

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DatabaseNameFromDSN

func DatabaseNameFromDSN(u *url.URL) string

func Register

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

func WithExecutor

func WithExecutor(ctx context.Context, e Executor) context.Context

Types

type Adaptor

type Adaptor interface {
	DB

	DriverName() string
	Schema() string
	Endpoint() string

	Dialect() Dialect
	Catalog(context.Context) (builder.Catalog, error)
}

func Open

func Open(ctx context.Context, dsn string) (Adaptor, error)

type Connector

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

type DB

type DB interface {
	Exec(context.Context, frag.Fragment) (sql.Result, error)
	Query(context.Context, frag.Fragment) (*sql.Rows, error)
	Tx(context.Context, func(context.Context) error) error
	Close() error
}

func Wrap

func Wrap(d *sql.DB, ew func(error) error) DB

type Dialect

type Dialect interface {
	CreateSchema(string) frag.Fragment
	SwitchSchema(string) frag.Fragment

	CreateTableIfNotExists(t builder.Table) []frag.Fragment
	DropTable(t builder.Table) frag.Fragment
	TruncateTable(t builder.Table) frag.Fragment

	AddColumn(builder.Col) frag.Fragment
	DropColumn(builder.Col) frag.Fragment
	RenameColumn(builder.Col, builder.Col) frag.Fragment
	ModifyColumn(builder.Col, builder.Col) frag.Fragment

	AddIndex(key builder.Key) frag.Fragment
	DropIndex(key builder.Key) frag.Fragment

	DBType(builder.ColumnDef) frag.Fragment
	IsUnknownDatabaseError(error) bool
	IsConflictError(err error) bool
}

type Executor

type Executor interface {
	ExecContext(context.Context, string, ...any) (sql.Result, error)
	QueryContext(context.Context, string, ...any) (*sql.Rows, error)
}

func ExecutorFrom

func ExecutorFrom(ctx context.Context) Executor

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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