Interface: SqlDialect
このコンテンツはまだ日本語訳がありません。
Interface: SqlDialect
Section titled “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.
Properties
Section titled “Properties”
readonlyname:string
Defined in: server/src/sql/dialect.ts:45
supportsDropColumn
Section titled “supportsDropColumn”
readonlysupportsDropColumn:boolean
Defined in: server/src/sql/dialect.ts:88
Can this backend drop columns / change types via ALTER TABLE?
Methods
Section titled “Methods”identifier()
Section titled “identifier()”identifier(
name):string
Defined in: server/src/sql/dialect.ts:47
Quote an identifier (table or column name).
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”string
placeholder()
Section titled “placeholder()”placeholder(
index):string
Defined in: server/src/sql/dialect.ts:49
Placeholder for the Nth (1-based) parameter.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”string
columnType()
Section titled “columnType()”columnType(
kind):string
Defined in: server/src/sql/dialect.ts:51
SQL type for a schema ColumnKind on this backend.
Parameters
Section titled “Parameters”ColumnKind
Returns
Section titled “Returns”string
emitChangesLogDdl()
Section titled “emitChangesLogDdl()”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.
Parameters
Section titled “Parameters”changesTable
Section titled “changesTable”string
Returns
Section titled “Returns”string[]
emitTriggers()
Section titled “emitTriggers()”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).
Parameters
Section titled “Parameters”tableName
Section titled “tableName”string
columnNames
Section titled “columnNames”readonly string[]
TriggerContext
fileColumns?
Section titled “fileColumns?”readonly string[]
Returns
Section titled “Returns”string[]
introspectSchema()
Section titled “introspectSchema()”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.
Parameters
Section titled “Parameters”DdlIntrospector
Returns
Section titled “Returns”Promise<TableShape[]>
emitAddColumn()
Section titled “emitAddColumn()”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.
Parameters
Section titled “Parameters”tableName
Section titled “tableName”string
ColumnShape
Returns
Section titled “Returns”string
emitDropTriggers()
Section titled “emitDropTriggers()”emitDropTriggers(
tableName,fileColumns?):string[]
Defined in: server/src/sql/dialect.ts:86
DROP TRIGGER statements for the plasma triggers on a user table.
Parameters
Section titled “Parameters”tableName
Section titled “tableName”string
fileColumns?
Section titled “fileColumns?”readonly string[]
Returns
Section titled “Returns”string[]