Documentation ¶
Index ¶
Constants ¶
View Source
const ( SqliteIndex = iota MysqlIndex PostgresIndex PgxIndex )
Variables ¶
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() int // String returns the name of this dialect. String() string // Alias is an alternative name for this dialect. Alias() string // Quoter is the tool used for quoting identifiers. Quoter() Quoter // WithQuoter returns a modified Dialect with a given quoter. WithQuoter(q Quoter) Dialect FieldAsColumn(field *schema.Field) string TruncateDDL(tableName string, force bool) []string CreateTableSettings() string InsertHasReturningPhrase() bool ShowTables() string ReplacePlaceholders(sql string, args []interface{}) string Placeholders(n int) string HasNumberedPlaceholders() bool }
Dialect is an abstraction of a type of database.
var Mysql Dialect = mysql(mySqlQuoter)
var Pgx Dialect = pgx{}
var Postgres Dialect = postgres(ansiQuoter)
var Sqlite Dialect = sqlite(ansiQuoter)
func PickDialect ¶
PickDialect finds a dialect that matches by name, ignoring letter case. It returns nil if not found.
type Quoter ¶
type Quoter interface { Quote(identifier string) string QuoteN(identifiers []string) []string QuoteW(w StringWriter, identifier string) }
Quoter wraps identifiers in quote marks. Compound identifers (i.e. those with an alias prefix) are handled according to SQL grammar.
var ( // AnsiQuoter wraps identifiers in double quotes. AnsiQuoter Quoter = ansiQuoter // MySqlQuoter wraps identifiers in back-ticks. MySqlQuoter Quoter = mySqlQuoter // NoQuoter leaves identifiers unquoted. NoQuoter Quoter = noQuoter // DefaultQuoter is used by default. Change this to affect the default setting for every // SQL construction function. DefaultQuoter = AnsiQuoter )
type StringWriter ¶
StringWriter is an interface that wraps the WriteString method. Note that bytes.Buffer happens to implement this interface.
Click to show internal directories.
Click to hide internal directories.