Skip to content

Interface: SqlDialect

Defined in: server/src/sql/dialect.ts:44

Dialect abstraction so the same AST compiler emits SQL text that fits the target driver: SQLite (D1) uses ? placeholders, Postgres uses $N.

Beyond the placeholder / identifier basics, the dialect owns the DDL for plasma’s sync-side machinery: column types on user tables, the changes log itself, and the AFTER-write triggers that copy rows into it. Adding a new backend is now a single value’s worth of methods.

readonly name: string

Defined in: server/src/sql/dialect.ts:45


readonly supportsDropColumn: boolean

Defined in: server/src/sql/dialect.ts:88

Can this backend drop columns / change types via ALTER TABLE?

identifier(name): string

Defined in: server/src/sql/dialect.ts:47

Quote an identifier (table or column name).

string

string


placeholder(index): string

Defined in: server/src/sql/dialect.ts:49

Placeholder for the Nth (1-based) parameter.

number

string


columnType(kind): string

Defined in: server/src/sql/dialect.ts:51

SQL type for a schema ColumnKind on this backend.

ColumnKind

string


emitChangesLogDdl(changesTable): string[]

Defined in: server/src/sql/dialect.ts:57

DDL for _plasma_changes — the auto-incrementing row-version log. SQLite uses INTEGER PRIMARY KEY AUTOINCREMENT; Postgres uses BIGSERIAL PRIMARY KEY. Also emits its index.

string

string[]


emitTriggers(tableName, columnNames, ctx, fileColumns?): string[]

Defined in: server/src/sql/dialect.ts:68

AFTER {INSERT,UPDATE,DELETE} triggers on a user table tableName with the given columnNames. Rows are copied into ctx.changesTable with origin attribution read from ctx.originTable.

When fileColumns is provided (v0.3+), additional triggers maintain _plasma_blob_refs / _plasma_blobs state so cascade / setNull child writes stay observable (the SQL engine’s write observer bypasses those paths — see spec §FR-5 hybrid design).

string

readonly string[]

TriggerContext

readonly string[]

string[]


introspectSchema(x): Promise<TableShape[]>

Defined in: server/src/sql/dialect.ts:79

Read the current user-table shape out of the live database. Used by runMigrations to compute a diff against the declared schema. Internal tables (_plasma_*) must be excluded.

DdlIntrospector

Promise<TableShape[]>


emitAddColumn(tableName, col): string

Defined in: server/src/sql/dialect.ts:84

ADD COLUMN DDL. SQLite supports only column-add through this path; Postgres accepts full column definitions.

string

ColumnShape

string


emitDropTriggers(tableName, fileColumns?): string[]

Defined in: server/src/sql/dialect.ts:86

DROP TRIGGER statements for the plasma triggers on a user table.

string

readonly string[]

string[]