Skip to main content
zerotal

Documentation


Documentation / @zerotal/orm / index / PostgresDialect

Class: PostgresDialect

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:7

PostgreSQL strategy — information_schema introspection, EXTRACT()/casts for date parts, pg_advisory_lock for advisory locks.

Implements

Constructors

Constructor

new PostgresDialect(): PostgresDialect

Returns

PostgresDialect

Properties

name

readonly name: "postgres"

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:8

Implementation of

SqlDialect.name


supportsAdvisoryLocks

readonly supportsAdvisoryLocks: true = true

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:9

Whether the engine supports application-level advisory locks.

Implementation of

SqlDialect.supportsAdvisoryLocks

Methods

hasTableSql()

hasTableSql(table): DialectQuery

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:11

Introspection query returning at least one row when table exists.

Parameters

table

string

Returns

DialectQuery

Implementation of

SqlDialect.hasTableSql


hasColumnSql()

hasColumnSql(table, column): DialectQuery

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:18

Introspection query returning at least one row when column exists on table.

Parameters

table

string

column

string

Returns

DialectQuery

Implementation of

SqlDialect.hasColumnSql


dateExpr()

dateExpr(part, column): string

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:27

SQL expression extracting a date part from column. The caller must validate column as a safe identifier first — the expression is interpolated verbatim.

Parameters

part

DatePart

column

string

Returns

string

Implementation of

SqlDialect.dateExpr


autoIncrementColumn()

autoIncrementColumn(column): string

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:42

The column definition for an auto-incrementing integer primary key.

Every engine spells this differently and none of them accept SQLite's INTEGER PRIMARY KEY AUTOINCREMENT: PostgreSQL wants a serial/identity type, MySQL wants AUTO_INCREMENT. Hard-coding the SQLite form meant the first migrate against PostgreSQL died on a syntax error and MySQL on error 1064 — before any of the dialect-aware hasTable/ALTER handling downstream got a chance to matter.

Parameters

column

string

Already-validated column name.

Returns

string

The full column fragment, type and constraints included.

Implementation of

SqlDialect.autoIncrementColumn


advisoryLockSql()

advisoryLockSql(key): DialectQuery

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:48

Statement acquiring an advisory lock (blocking), or null when unsupported.

Parameters

key

number

Returns

DialectQuery

Implementation of

SqlDialect.advisoryLockSql


advisoryUnlockSql()

advisoryUnlockSql(key): DialectQuery

Defined in: packages/orm/src/db/dialects/PostgresDialect.ts:52

Statement releasing an advisory lock, or null when unsupported.

Parameters

key

number

Returns

DialectQuery

Implementation of

SqlDialect.advisoryUnlockSql