driver

package
v0.62.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: BSD-2-Clause Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllDialects = []Dialect{Sqlite(), Mysql(), Postgres(), Pgx()}

AllDialects lists all currently-supported dialects.

Functions

This section is empty.

Types

type Dialect

type Dialect interface {
	// Index returns a consistent ID for this dialect, regardless of other settings.
	Index() dialect.Dialect
	// String returns the name (and quoter if present) of this dialect.
	String() string
	// Name returns the name of this dialect.
	Name() string
	// Alias is an alternative name for this dialect.
	Alias() string
	// Config is the dialect config wrapped in this driver adapter.
	Config() dialect.DialectConfig
	// Quoter is the tool used for quoting identifiers.
	Quoter() quote.Quoter
	// WithQuoter returns a modified Dialect with a given quoter.
	WithQuoter(q quote.Quoter) Dialect

	FieldAsColumn(field *schema.Field) string
	TruncateDDL(tableName string, force bool) []string
	CreateTableSettings() string
	ShowTables() string

	// ReplacePlaceholders alters a query string by replacing the '?' placeholders with the appropriate
	// placeholders needed by this dialect. For MySQL and SQlite3, the string is returned unchanged.
	ReplacePlaceholders(sql string, args []interface{}) string
	// Placeholders returns a comma-separated list of n placeholders.
	Placeholders(n int) string
	// HasNumberedPlaceholders returns true for dialects such as PostgreSQL that use numbered placeholders.
	HasNumberedPlaceholders() bool
	// HasLastInsertId returns true for dialects such as MySQL that return a last-insert ID after each
	// INSERT. This allows the corresponding feature of the database/sql API to work.
	// It is the inverse of InsertHasReturningPhrase.
	HasLastInsertId() bool
	// InsertHasReturningPhrase returns true for dialects such as Postgres that use a RETURNING phrase to
	// obtain the last-insert ID after each INSERT.
	// It is the inverse of HasLastInsertId.
	InsertHasReturningPhrase() bool
}

Dialect is an abstraction of a type of database.

func Mysql

func Mysql(d ...dialect.DialectConfig) Dialect

func Pgx

func Pgx(d ...dialect.DialectConfig) Dialect

func PickDialect

func PickDialect(name string) Dialect

PickDialect finds a dialect that matches by name, ignoring letter case. It returns nil if not found.

func Postgres

func Postgres(d ...dialect.DialectConfig) Dialect

func Sqlite

func Sqlite(d ...dialect.DialectConfig) Dialect

type StringWriter

type StringWriter interface {
	io.Writer
	WriteString(s string) (n int, err error)
	String() string
}

StringWriter is an interface that wraps the WriteString method. Note that bytes.Buffer happens to implement this interface.

func Adapt

func Adapt(w io.Writer) StringWriter

Adapt wraps an io.Writer as a StringWriter.

Jump to

Keyboard shortcuts

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