sql

package
v0.0.0-...-ce651b8 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err means "no such row" in this backend. GORM already has a single canonical sentinel, so there is nothing to wrap — the bare driver error returned by First()/Take() is matched directly.

func Models

func Models() []any

Models is the full set of tables this provider owns, in migration order. Kept in one place so alternative migrators cannot drift from AutoMigrate.

Types

type Dependencies

type Dependencies struct {
	Log *zerolog.Logger
}

Dependencies struct the sql data store provider

type Options

type Options struct {
	// Migrate replaces GORM AutoMigrate. SereneDB rejects the
	// ALTER COLUMN ... TYPE that AutoMigrate re-issues on every boot, so it
	// supplies its own hand-written, versioned DDL instead.
	Migrate func(*gorm.DB) error
	// WrapPool wraps the connection pool before GORM sees it. SereneDB uses it
	// to retry write conflicts its optimistic MVCC raises. PostgreSQL family
	// only.
	WrapPool func(*stdsql.DB) gorm.ConnPool
	// SkipDefaultTransaction turns off the transaction GORM wraps around every
	// single Create/Update/Delete. Only SereneDB sets it: that implicit
	// transaction routes every write through BeginTx, where a conflict aborts
	// the whole transaction and cannot be retried statement-by-statement. The
	// schemas here carry no GORM associations, so one write is one statement
	// and the wrapper buys nothing to begin with. Explicit Transaction() blocks
	// are unaffected.
	SkipDefaultTransaction bool
	// RetryTransactions replays an explicit transaction from the start when it
	// aborts with a serialization failure (SQLSTATE 40001). Only SereneDB sets
	// it: its optimistic MVCC aborts contended transactions instead of making
	// them wait, and a statement cannot be retried inside an aborted
	// transaction — only the whole block can. Every other backend keeps a
	// single attempt, exactly as before.
	RetryTransactions bool
}

Options customise how the provider is built. They exist for engines that speak a supported wire protocol but differ underneath; all are zero for every database type this package handles directly, so the default path is unchanged.

type Provider

type Provider = provider

Provider is the SQL storage provider. It is exported so wire-compatible engines that need to override a handful of methods (see internal/storage/db/serenedb) can embed it instead of duplicating the whole backend.

func NewProvider

func NewProvider(
	config *config.Config,
	deps *Dependencies,
) (*Provider, error)

NewProvider returns a new SQL provider

func NewProviderWithOptions

func NewProviderWithOptions(
	config *config.Config,
	deps *Dependencies,
	opts Options,
) (*Provider, error)

NewProviderWithOptions returns a new SQL provider with the given hooks applied. See Options.

Directories

Path Synopsis
Package sqlitedialect is a pure-Go GORM SQLite dialector.
Package sqlitedialect is a pure-Go GORM SQLite dialector.

Jump to

Keyboard shortcuts

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