dialect

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MySQL    = "mysql"
	SQLite   = "sqlite3"
	Postgres = "postgres"
)

Dialect names for external usage.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugDriver

type DebugDriver struct {
	Driver // underlying driver.
	// contains filtered or unexported fields
}

DebugDriver is a driver that logs all driver operations.

func (*DebugDriver) BeginTx

func (d *DebugDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)

BeginTx adds an log-id for the transaction and calls the underlying driver BeginTx command if it's supported.

func (*DebugDriver) Exec

func (d *DebugDriver) Exec(ctx context.Context, query string, args, v interface{}) error

Exec logs its params and calls the underlying driver Exec method.

func (*DebugDriver) Query

func (d *DebugDriver) Query(ctx context.Context, query string, args, v interface{}) error

Query logs its params and calls the underlying driver Query method.

func (*DebugDriver) Tx

func (d *DebugDriver) Tx(ctx context.Context) (Tx, error)

Tx adds an log-id for the transaction and calls the underlying driver Tx command.

type DebugTx

type DebugTx struct {
	Tx // underlying transaction.
	// contains filtered or unexported fields
}

DebugTx is a transaction implementation that logs all transaction operations.

func (*DebugTx) Commit

func (d *DebugTx) Commit() error

Commit logs this step and calls the underlying transaction Commit method.

func (*DebugTx) Exec

func (d *DebugTx) Exec(ctx context.Context, query string, args, v interface{}) error

Exec logs its params and calls the underlying transaction Exec method.

func (*DebugTx) Query

func (d *DebugTx) Query(ctx context.Context, query string, args, v interface{}) error

Query logs its params and calls the underlying transaction Query method.

func (*DebugTx) Rollback

func (d *DebugTx) Rollback() error

Rollback logs this step and calls the underlying transaction Rollback method.

type Driver

type Driver interface {
	ExecQuerier
	// Tx starts and returns a new transaction.
	// The provided context is used until the transaction is committed or rolled back.
	Tx(context.Context) (Tx, error)
	// Close closes the underlying connection.
	Close() error
	// Dialect returns the dialect name of the driver.
	Dialect() string
}

Driver is the interface that wraps all necessary operations for ent clients.

func Debug

func Debug(d Driver, logger ...func(...interface{})) Driver

Debug gets a driver and an optional logging function, and returns a new debugged-driver that prints all outgoing operations.

func DebugWithContext

func DebugWithContext(d Driver, logger func(context.Context, ...interface{})) Driver

DebugWithContext gets a driver and a logging function, and returns a new debugged-driver that prints all outgoing operations with context.

type ExecQuerier

type ExecQuerier interface {
	// Exec executes a query that does not return records. For example, in SQL, INSERT or UPDATE.
	// It scans the result into the pointer v. For SQL drivers, it is dialect/sql.Result.
	Exec(ctx context.Context, query string, args, v interface{}) error
	// Query executes a query that returns rows, typically a SELECT in SQL.
	// It scans the result into the pointer v. For SQL drivers, it is *dialect/sql.Rows.
	Query(ctx context.Context, query string, args, v interface{}) error
}

ExecQuerier wraps the 2 database operations.

type Tx

type Tx interface {
	ExecQuerier
	driver.Tx
}

Tx wraps the Exec and Query operations in transaction.

func NopTx

func NopTx(d Driver) Tx

NopTx returns a Tx with a no-op Commit / Rollback methods wrapping the provided Driver d.

Directories

Path Synopsis
sql
Package sql provides wrappers around the standard database/sql package to allow the generated code to interact with a statically-typed API.
Package sql provides wrappers around the standard database/sql package to allow the generated code to interact with a statically-typed API.
schema
Package schema contains all schema migration logic for SQL dialects.
Package schema contains all schema migration logic for SQL dialects.
sqlgraph
Package sqlgraph provides graph abstraction capabilities on top of sql-based databases for ent codegen.
Package sqlgraph provides graph abstraction capabilities on top of sql-based databases for ent codegen.

Jump to

Keyboard shortcuts

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