Documentation
¶
Overview ¶
Package postgres implements the dialects.Dialect interface for PostgreSQL.
Importing the package registers the dialect with dialects.Register under the "postgres" driver name. New returns a dialect backed by PosgtgresCore, and Config describes how to connect to a PostgreSQL database.
Index ¶
- func New() dialects.Dialect
- func UsePostgres()
- type Config
- type PosgtgresCore
- func (*PosgtgresCore) AutoIncrement() string
- func (p *PosgtgresCore) Binding() string
- func (*PosgtgresCore) CurrentTime() string
- func (*PosgtgresCore) DataType(t dialects.DataType) string
- func (s *PosgtgresCore) Escape(v any) string
- func (s *PosgtgresCore) Features() dialects.Features
- func (*PosgtgresCore) Identifier(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UsePostgres ¶
func UsePostgres()
UsePostgres registers the PostgreSQL dialect under the "postgres" driver name.
Types ¶
type Config ¶
Config describes how to connect to a PostgreSQL database. DisableSSL opts out of SSL.
func (*Config) DataSourceName ¶
DataSourceName returns the key=value DSN used to connect to the database.
func (*Config) DriverName ¶
DriverName returns the database driver name, "postgres".
type PosgtgresCore ¶
type PosgtgresCore struct {
// contains filtered or unexported fields
}
PosgtgresCore implements generic.Core for PostgreSQL. It quotes identifiers with double quotes, uses incrementing $1, $2, ... bindings, and supports RETURNING.
func (*PosgtgresCore) AutoIncrement ¶
func (*PosgtgresCore) AutoIncrement() string
AutoIncrement returns the clause that makes a column an auto-incrementing primary key in PostgreSQL.
func (*PosgtgresCore) Binding ¶
func (p *PosgtgresCore) Binding() string
Binding returns the next PostgreSQL binding placeholder in the sequence ($1, $2, ...).
func (*PosgtgresCore) CurrentTime ¶
func (*PosgtgresCore) CurrentTime() string
CurrentTime returns the PostgreSQL expression for the current timestamp.
func (*PosgtgresCore) DataType ¶
func (*PosgtgresCore) DataType(t dialects.DataType) string
DataType maps a dialects.DataType to a PostgreSQL column type.
func (*PosgtgresCore) Escape ¶
func (s *PosgtgresCore) Escape(v any) string
Escape renders v as a SQL literal, doubling embedded single quotes in strings, rendering booleans as TRUE or FALSE, and JSON-marshaling unknown types.
func (*PosgtgresCore) Features ¶
func (s *PosgtgresCore) Features() dialects.Features
Features reports the capabilities supported by PostgreSQL, which include RETURNING.
func (*PosgtgresCore) Identifier ¶
func (*PosgtgresCore) Identifier(s string) string
Identifier returns s quoted as a PostgreSQL identifier. A "*" segment is left unquoted.