Documentation
¶
Overview ¶
Package dialect is the SQL dialect kind parse compiles for: the placeholder and identifier rules of PostgreSQL and SQLite. The filter and patch dialects embed it and add their SQL.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownDSN = errors.New("parse: unknown DSN scheme")
ErrUnknownDSN is returned by FromDSN for a DSN whose scheme names no supported database.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect interface {
// Name is "postgres" or "sqlite".
Name() string
// Placeholder is the nth parameter's placeholder (1-based): "$1" on
// PostgreSQL, "?1" on SQLite.
Placeholder(n int) string
// QuoteIdent quotes an identifier with double quotes, doubling any
// quote inside it.
QuoteIdent(name string) string
}
Dialect is the dialect-specific part of a statement: its name, its placeholders and identifier quoting.
type Postgres ¶
type Postgres struct{}
Postgres is PostgreSQL (and CockroachDB): $n placeholders.
func (Postgres) Placeholder ¶
Placeholder returns "$n". A non-positive n is a statement builder's bug and panics: it would render invalid SQL.
func (Postgres) QuoteIdent ¶
QuoteIdent quotes name per the SQL standard.
type SQLite ¶
type SQLite struct{}
SQLite is SQLite: ?n placeholders.
func (SQLite) Placeholder ¶
Placeholder returns "?n"; a non-positive n panics, as for Postgres.
func (SQLite) QuoteIdent ¶
QuoteIdent quotes name per the SQL standard.