postgres

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() dialects.Dialect

New returns a dialect that renders SQL for PostgreSQL.

func UsePostgres

func UsePostgres()

UsePostgres registers the PostgreSQL dialect under the "postgres" driver name.

Types

type Config

type Config struct {
	Username   string
	Password   string
	Host       string
	Database   string
	DisableSSL bool
}

Config describes how to connect to a PostgreSQL database. DisableSSL opts out of SSL.

func (*Config) DataSourceName

func (c *Config) DataSourceName() string

DataSourceName returns the key=value DSN used to connect to the database.

func (*Config) DriverName

func (c *Config) DriverName() string

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.

Jump to

Keyboard shortcuts

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