Documentation
¶
Overview ¶
Package postgres provides the PostgreSQL dialect.
Importing it registers the dialect under "postgres", "postgresql" and "pgx":
import _ "github.com/gruberchris/rung/dialect/postgres"
It targets PostgreSQL 12 and later and uses github.com/jackc/pgx/v5 through database/sql.
Index ¶
- type Dialect
- func (Dialect) DropTablesStatement(quoted []string) string
- func (Dialect) LedgerDDL() string
- func (Dialect) LedgerExistsQuery() string
- func (Dialect) ListTablesQuery() string
- func (Dialect) MigrationsDir() string
- func (Dialect) Name() string
- func (Dialect) OpenForMigrations(dsn string) (*sql.DB, error)
- func (Dialect) QuoteIdentifier(name string) string
- func (Dialect) Rebind(query string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialect ¶
type Dialect struct{}
Dialect implements rung.Dialect for PostgreSQL.
func (Dialect) DropTablesStatement ¶
DropTablesStatement drops every named table in one statement.
CASCADE means foreign keys and dependency ordering do not matter, so there is no need to compute a safe drop order.
func (Dialect) LedgerExistsQuery ¶
LedgerExistsQuery reports whether the ledger exists in the current schema.
func (Dialect) ListTablesQuery ¶
ListTablesQuery lists the tables in the current schema, for rung/reset.
func (Dialect) MigrationsDir ¶
MigrationsDir returns "postgres".
func (Dialect) OpenForMigrations ¶
OpenForMigrations opens a handle using the simple query protocol.
That is a requirement, not a preference: migration files hold several statements, and pgx's default extended protocol permits exactly one per Exec. An application's own pool should keep the default.
func (Dialect) QuoteIdentifier ¶
QuoteIdentifier quotes a SQL identifier.
Table names come from the catalogue rather than from user input, but they are interpolated into a statement that cannot be parameterised, so they are quoted rather than trusted.