sql

package
v1.41.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuilderFor added in v1.14.0

func BuilderFor(db *sql.DB, driver Driver, preparedStatementsEnabled bool) sq.StatementBuilderType

BuilderFor returns a squirrel statement builder which decorates the provided sql.DB configured for the provided driver.

func WithMigrate added in v1.14.0

func WithMigrate(o *Options)

func WithSSLDisabled added in v1.14.0

func WithSSLDisabled(o *Options)

Types

type Driver

type Driver uint8

Driver represents a database driver

const (

	// SQLite ...
	SQLite Driver
	// Postgres ...
	Postgres
	// MySQL ...
	MySQL
	// CockroachDB ...
	CockroachDB
	// LibSQL ...
	LibSQL
	// Clickhouse ...
	Clickhouse
)

func Open

func Open(cfg config.Config, opts ...Option) (*sql.DB, Driver, error)

Open opens a connection to the db

func (Driver) AdaptError added in v1.15.0

func (d Driver) AdaptError(err error) error

AdaptError converts specific known-driver errors into wrapped storage errors.

func (Driver) Migrations added in v1.29.0

func (d Driver) Migrations() string

func (Driver) String

func (d Driver) String() string

type JSONField added in v1.15.0

type JSONField[T any] struct {
	T T
}

func (*JSONField[T]) Scan added in v1.15.0

func (f *JSONField[T]) Scan(v any) error

func (*JSONField[T]) Value added in v1.15.0

func (f *JSONField[T]) Value() (driver.Value, error)

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

Migrator is responsible for migrating the database schema

func NewAnalyticsMigrator added in v1.37.0

func NewAnalyticsMigrator(cfg config.Config, logger *zap.Logger) (*Migrator, error)

NewAnalyticsMigrator returns a migrator for analytics databases

func NewMigrator

func NewMigrator(cfg config.Config, logger *zap.Logger) (*Migrator, error)

NewMigrator creates a new Migrator

func (*Migrator) Close

func (m *Migrator) Close() (source, db error)

Close closes the source and db

func (*Migrator) Drop added in v1.20.0

func (m *Migrator) Drop() error

Drop drops the database

func (*Migrator) Up added in v1.15.0

func (m *Migrator) Up(force bool) error

Up runs any pending migrations

type MockDriverContext added in v1.41.0

type MockDriverContext struct {
	mock.Mock
}

MockDriverContext is an autogenerated mock type for the DriverContext type

func NewMockDriverContext added in v1.41.0

func NewMockDriverContext(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockDriverContext

NewMockDriverContext creates a new instance of MockDriverContext. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockDriverContext) OpenConnector added in v1.41.0

func (_m *MockDriverContext) OpenConnector(name string) (driver.Connector, error)

OpenConnector provides a mock function with given fields: name

type NullableTimestamp added in v1.15.0

type NullableTimestamp Timestamp

func (*NullableTimestamp) Scan added in v1.15.0

func (t *NullableTimestamp) Scan(value interface{}) error

func (*NullableTimestamp) Value added in v1.15.0

func (t *NullableTimestamp) Value() (driver.Value, error)

type Option added in v1.14.0

type Option func(*Options)

type Options added in v1.14.0

type Options struct {
	// contains filtered or unexported fields
}

type Timestamp added in v1.15.0

type Timestamp struct {
	*timestamppb.Timestamp
}

func (*Timestamp) Scan added in v1.15.0

func (t *Timestamp) Scan(value interface{}) error

func (*Timestamp) Value added in v1.15.0

func (t *Timestamp) Value() (driver.Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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