sqltuple

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTableNotFound = tuple.ErrTableNotFound

Functions

func New

func New(db *sql.DB, dbname string, dia Dialect) tuple.Store

func Open

func Open(name, addr, db string) (tuple.Store, error)

func OpenSQL

func OpenSQL(name, addr, db string) (*sql.DB, error)

func Register

func Register(reg Registration)

Register globally registers a database driver.

Types

type Builder

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

func (*Builder) Args

func (b *Builder) Args() []interface{}

func (*Builder) EqPlace

func (b *Builder) EqPlace(names []string, args []interface{})

func (*Builder) EqPlaceAnd

func (b *Builder) EqPlaceAnd(names []string, args []interface{})

func (*Builder) Idents

func (b *Builder) Idents(names ...string)

func (*Builder) Literal

func (b *Builder) Literal(s string)

func (*Builder) OpPlace

func (b *Builder) OpPlace(names []string, op string, args []interface{})

func (*Builder) OpPlaceAnd

func (b *Builder) OpPlaceAnd(names []string, op string, args []interface{})

func (*Builder) Place

func (b *Builder) Place(args ...interface{})

func (*Builder) Reset

func (b *Builder) Reset()

func (*Builder) String

func (b *Builder) String() string

func (*Builder) Write

func (b *Builder) Write(s string)

type DSNFunc

type DSNFunc func(addr, ns string) (string, error)

DSNFunc is a function for building a Data Source Name for SQL driver, given a address and the database name.

type Dialect

type Dialect struct {
	Errors              ErrorFunc
	BytesType           string
	StringType          string
	BytesKeyType        string
	StringKeyType       string
	TimeType            string
	StringTypeCollation string
	AutoType            string
	QuoteIdentifierFunc func(s string) string
	Placeholder         func(i int) string
	// DefaultSchema will be used to query table metadata.
	// If not set, defaults to the database name.
	DefaultSchema string
	// ListColumns is a query that will be executed to get columns info.
	// Two parameters will be passed to the query: current schema and the table name.
	ListColumns string
	// Unsigned indicates that a database supports UNSIGNED modifier for integer types.
	Unsigned bool
	// NoIteratorsWhenMutating mark indicates that backend cannot run iterators and
	// mutations in the same transaction (example: SELECT and DELETE while iterating).
	NoIteratorsWhenMutating bool
	// ReplaceStmt indicates that backend supports REPLACE statement.
	ReplaceStmt bool
	// OnConflict indicates that backend supports ON CONFLICT in INSERT statement.
	OnConflict bool
	// Returning indicates that INSERT queries needs an RETURNING keyword to return last
	// inserted id.
	Returning           bool
	ColumnCommentInline func(s string) string
	ColumnCommentSet    func(b *Builder, tbl, col, s string)
}

func (*Dialect) NewBuilder

func (d *Dialect) NewBuilder() *Builder

func (*Dialect) QuoteIdentifier

func (d *Dialect) QuoteIdentifier(s string) string

func (*Dialect) QuoteString

func (d *Dialect) QuoteString(s string) string

func (*Dialect) SetDefaults

func (d *Dialect) SetDefaults()

type ErrorFunc

type ErrorFunc func(err error) error

type Registration

type Registration struct {
	base.Registration
	Driver  string
	DSN     DSNFunc
	Dialect Dialect
}

Registration is an information about the database driver.

func ByName

func ByName(name string) *Registration

ByName returns a registered database driver by it's name.

func List

func List() []Registration

List enumerates all globally registered database drivers.

Directories

Path Synopsis
all

Jump to

Keyboard shortcuts

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