PostgreSQL dialect implementation.

Generates Postgres-compatible SQL syntax including ON CONFLICT DO NOTHING, ON CONFLICT ... DO UPDATE SET, jsonb extraction operators, COALESCE(), GENERATED ALWAYS AS IDENTITY, and $N positional placeholders.

Implements

Constructors

Properties

name: "postgres" = ...

Dialect identifier.

Methods

  • Generate an INSERT OR IGNORE statement. SQLite: INSERT OR IGNORE INTO t (a, b) VALUES (?, ?) Postgres: INSERT INTO t (a, b) VALUES ($1, $2) ON CONFLICT DO NOTHING

    Parameters

    • table: string
    • columns: string[]
    • placeholders: string[]

    Returns string

  • Generate an INSERT OR REPLACE (upsert) statement. SQLite: INSERT OR REPLACE INTO t (a, b) VALUES (?, ?) Postgres: INSERT INTO t (a, b) VALUES ($1, $2) ON CONFLICT (pk) DO UPDATE SET ...

    Parameters

    • table: string
    • columns: string[]
    • placeholders: string[]
    • OptionalprimaryKey: string

      Required for Postgres ON CONFLICT clause. Defaults to first column.

    Returns string

  • Generate a JSON field extraction expression. SQLite: json_extract(col, '$.key') Postgres: (col::jsonb)->>'key'

    Parameters

    • column: string
    • jsonPath: string

    Returns string

  • Generate a null-coalesce expression. SQLite: ifnull(expr, fallback) Postgres: COALESCE(expr, fallback)

    Parameters

    • expr: string
    • fallback: string

    Returns string

  • Generate a PRAGMA statement or equivalent. SQLite: PRAGMA key = value Postgres: returns null (skip — Postgres enforces FKs by default, etc.)

    Parameters

    • _key: string
    • _value: string

    Returns null | string