Documentation / @zerotal/orm / index / SqlDialect
Interface: SqlDialect
Defined in: packages/orm/src/db/dialects/types.ts:29
Per-engine SQL strategy.
Example
const d = getDialect("postgres");
const { sql, params } = d.hasTableSql("users");
Properties
name
readonlyname:DialectName
Defined in: packages/orm/src/db/dialects/types.ts:30
supportsAdvisoryLocks
readonlysupportsAdvisoryLocks:boolean
Defined in: packages/orm/src/db/dialects/types.ts:60
Whether the engine supports application-level advisory locks.
Methods
hasTableSql()
hasTableSql(
table):DialectQuery
Defined in: packages/orm/src/db/dialects/types.ts:33
Introspection query returning at least one row when table exists.
Parameters
table
string
Returns
hasColumnSql()
hasColumnSql(
table,column):DialectQuery
Defined in: packages/orm/src/db/dialects/types.ts:36
Introspection query returning at least one row when column exists on table.
Parameters
table
string
column
string
Returns
dateExpr()
dateExpr(
part,column):string
Defined in: packages/orm/src/db/dialects/types.ts:43
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
column
string
Returns
string
autoIncrementColumn()
autoIncrementColumn(
column):string
Defined in: packages/orm/src/db/dialects/types.ts:57
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.
advisoryLockSql()
advisoryLockSql(
key):DialectQuery|null
Defined in: packages/orm/src/db/dialects/types.ts:63
Statement acquiring an advisory lock (blocking), or null when unsupported.
Parameters
key
number
Returns
DialectQuery | null
advisoryUnlockSql()
advisoryUnlockSql(
key):DialectQuery|null
Defined in: packages/orm/src/db/dialects/types.ts:66
Statement releasing an advisory lock, or null when unsupported.
Parameters
key
number
Returns
DialectQuery | null