Help us shape the future of Go! Take the 2026 Go Developer Survey

dialect

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 34

Documentation

Index

Constants

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

Variables

View Source
var ErrNoRows = sql.ErrNoRows

ErrNoRows is returned when a statement that must produce a row produces none. It is the database/sql sentinel so that errors.Is(err, sql.ErrNoRows) keeps working.

Functions

func QualifiedTable added in v0.3.1

func QualifiedTable(schema, table string) string

QualifiedTable returns the schema-qualified table name used in Statement.

func WithStatement added in v0.3.1

func WithStatement(ctx context.Context, statement *Statement) context.Context

Types

type Capabilities added in v0.3.0

type Capabilities struct {
	ReturningOld             bool
	ConflictDoSelect         bool
	NativeArray              bool
	MultiRowReturningOrdered bool
}

type ConstraintError added in v0.3.0

type ConstraintError struct {
	Kind       ConstraintKind
	Constraint string
	Table      string
	Err        error
}

ConstraintError is returned by drivers when a statement violates a constraint.

func (*ConstraintError) Error added in v0.3.0

func (e *ConstraintError) Error() string

func (*ConstraintError) Unwrap added in v0.3.0

func (e *ConstraintError) Unwrap() error

type ConstraintKind added in v0.3.0

type ConstraintKind uint8

ConstraintKind classifies a violated database constraint.

const (
	Unique ConstraintKind = iota
	ForeignKey
	Check
	NotNull
	Exclusion
)

Constraint kinds reported by drivers.

type DebugDriver

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

func (*DebugDriver) BeginTx

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

func (*DebugDriver) DB added in v0.3.0

func (d *DebugDriver) DB() *sql.DB

DB exposes the migration connection when supported by the wrapped driver.

func (*DebugDriver) Exec

func (d *DebugDriver) Exec(ctx context.Context, query string, args []any) (Result, error)

func (*DebugDriver) Query

func (d *DebugDriver) Query(ctx context.Context, query string, args []any) (Rows, error)

func (*DebugDriver) Tx

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

type DebugTx

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

func (*DebugTx) Commit

func (d *DebugTx) Commit() error

func (*DebugTx) Exec

func (d *DebugTx) Exec(ctx context.Context, query string, args []any) (Result, error)

func (*DebugTx) Query

func (d *DebugTx) Query(ctx context.Context, query string, args []any) (Rows, error)

func (*DebugTx) Rollback

func (d *DebugTx) Rollback() error

type Dialect added in v0.3.0

type Dialect string

type Driver

type Driver interface {
	ExecQuerier
	Tx(ctx context.Context) (Tx, error)
	BeginTx(ctx context.Context, opts *TxOptions) (Tx, error)
	Close() error
	Dialect() Dialect
	Capabilities() Capabilities
}

func Debug

func Debug(d Driver, logger ...func(...any)) Driver

func DebugWithContext

func DebugWithContext(d Driver, logger func(context.Context, ...any)) Driver

type ExecQuerier

type ExecQuerier interface {
	Exec(ctx context.Context, query string, args []any) (Result, error)
	Query(ctx context.Context, query string, args []any) (Rows, error)
}

type Result added in v0.3.0

type Result interface{ RowsAffected() (int64, error) }

type RowRef added in v0.3.1

type RowRef struct {
	Table string
	ID    any
}

type Rows added in v0.3.0

type Rows interface {
	Next() bool
	Scan(dest ...any) error
	Columns() ([]string, error)
	Close() error
	Err() error
}

type Statement added in v0.3.1

type Statement struct {
	Kind   StatementKind
	Tables []string
	Lock   bool
	// IDColumn names the primary key column of the queried node when the
	// statement selects it. Empty otherwise.
	IDColumn string
	// PointRead reports that the WHERE clause is a conjunction that pins the
	// result to specific rows of the node table (Tables[0]) by primary key or
	// unique columns. Rows in other tables may still affect the result.
	PointRead bool
	// RequestedIDs holds the primary key values a point read asked for. A
	// cache uses them to invalidate negative results when such rows appear.
	RequestedIDs []any
	// Rows lists the rows a write touched. sqlgraph fills it after the
	// statement executes, once RETURNING has been scanned, so readers must
	// consult it only after the rows are closed or Exec returned.
	Rows []RowRef
	// Bulk lists tables a write touched without identifying the rows.
	Bulk []string
}

Statement carries the structural metadata sqlgraph knows about a statement it is about to execute. Driver wrappers (caches, tracers) read it from the context. It travels in the context rather than through the Driver interface so that intermediate wrappers unaware of it cannot drop it.

Table names are schema-qualified ("schema.table") when a schema is set.

func StatementFrom added in v0.3.1

func StatementFrom(ctx context.Context) *Statement

type StatementKind added in v0.3.1

type StatementKind uint8
const (
	StatementRead StatementKind = iota + 1
	StatementWrite
)

type Tx

type Tx interface {
	ExecQuerier
	Commit() error
	Rollback() error
}

func NopTx

func NopTx(d Driver) Tx

type TxOptions added in v0.3.0

type TxOptions = sql.TxOptions

type UnsupportedError added in v0.3.0

type UnsupportedError struct {
	Feature string
	Dialect Dialect
}

UnsupportedError is returned when a feature is used on a dialect that lacks it.

func (*UnsupportedError) Error added in v0.3.0

func (e *UnsupportedError) Error() string

Directories

Path Synopsis
Package pg implements the driver boundary with native pgx codecs.
Package pg implements the driver boundary with native pgx codecs.
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.
Package sqlite uses ncruces SQLite through database/sql.
Package sqlite uses ncruces SQLite through database/sql.

Jump to

Keyboard shortcuts

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