Capability Matrix
The two database families share one model syntax, one set of generated types, and one client API. Configuration details are on each database page.
Overview
| Item | MySQL / MariaDB | PostgreSQL |
|---|---|---|
| Server version | MySQL 8.0.16+ / MariaDB 10.6+ | 14+ |
| Driver | mariadb | pg |
| Connection | Connection pool (configurable) | Connection pool (configurable) |
| Placeholder | ? | $1, $2 |
| Identifier quote | Backticks | Double quotes |
Client Capabilities
Fields of db.$capabilities:
| Field | MySQL / MariaDB | PostgreSQL |
|---|---|---|
returning | No | Yes |
isolationLevels | All three | All three |
Feature Differences
| Feature | MySQL / MariaDB | PostgreSQL |
|---|---|---|
| CRUD, relation queries, nested writes, aggregations | Yes | Yes |
| Soft delete, typed JSON, virtual fields | Yes | Yes |
| Versioned migrations | Yes | Yes |
createManyAndReturn, updateManyAndReturn | Yes ¹ | Yes |
upsert | Yes ² | Yes |
| Automatic rollback on migration failure | No ³ | Yes |
- No
RETURNINGon MySQL / MariaDB: bulk returning uses per-row writes and primary-key readback; see Create and Update. - A single native statement when conditions allow:
ON CONFLICT DO UPDATEon PostgreSQL,ON DUPLICATE KEY UPDATEon MySQL; MySQL's conditions are stricter, see upsert. - MySQL DDL implicitly commits; keep each migration doing one thing and inspect failures manually before
resolve. Isolation levels: Transactions.
Type Mapping
| Model type | MySQL / MariaDB | PostgreSQL |
|---|---|---|
int, bigint | BIGINT | BIGINT |
number | DOUBLE | DOUBLE PRECISION |
decimal(p, s) | DECIMAL(p, s) | NUMERIC(p, s) |
string, string(n) | VARCHAR(n) | VARCHAR(n) |
text | LONGTEXT | TEXT |
boolean | TINYINT(1) + value CHECK | BOOLEAN |
datetime | DATETIME(3) | TIMESTAMP(3) WITH TIME ZONE |
timestamp | BIGINT | BIGINT |
json<T> | JSON | JSONB |
bytes | LONGBLOB | BYTEA |
| String union | VARCHAR(191) + enum CHECK | VARCHAR(191) + enum CHECK |
int @id @auto | BIGINT + AUTO_INCREMENT | BIGINT + GENERATED ALWAYS AS IDENTITY |
string(n) defaults to n = 191 so that string maps to an indexable VARCHAR(191) on both databases, see Why string Defaults to 191. text is unbounded (LONGTEXT on MySQL, TEXT elsewhere) and cannot be a key or indexed, because MySQL cannot index LONGTEXT without a prefix. Client result types are uniform; storage precision and limits still differ:
| Model type | Client value |
|---|---|
int | A number within the safe range; out of range raises NUMERIC_OVERFLOW, never losing precision |
bigint | Decimal integer string preserving integer precision |
number | A finite number |
decimal | A string, for example "1234.50" |
string | string, length validated by Unicode code points |
text | string, no length limit |
boolean | boolean |
datetime, timestamp | Date object |
json<T> | A structurally validated JSON value |
bytes | Uint8Array |
| String union | A TypeScript string union |
int @id @auto | number, generated automatically on create |
Generated foreign keys inherit the target field's type and length; @map and @@map change names, not types.
Common Query Semantics
- Empty collection filters:
in: []matches nothing,notIn: []matches everything;NULLsorts first ascending, last descending; ordering is stable (primary key appended automatically); relation pagination is per parent, at most 200 parent keys per batch.
Remaining Differences
- String semantics: collation, case,
LIKE, and trailing-space comparison follow each database's own rules. - Index limits and concurrency: indexed byte length, row size, locks, deadlocks, and transaction conflicts are decided by the server.
Next Steps
- Adapters: connection options and type details per adapter
- Versioned Migrations: applying schema changes to a real database
- Transactions: isolation levels and failure semantics