Engines
This page lists the differences between the database engines supported by λORM.
λORM runs the same queries and stage commands on PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, MongoDB and SQLite (dialect SQLjs).
The same model gives the same results on every engine, except for the differences below.
These differences are checked by the engines lab, which runs the same tests on PostgreSQL 17, MySQL 8.4, MariaDB 11.4, SQL Server 2022, Oracle 23 Free and MongoDB 7.
Summary
| PostgreSQL | MySQL / MariaDB | SQL Server | Oracle | MongoDB | |
|---|---|---|---|---|---|
string without length |
TEXT |
VARCHAR(80) |
VARCHAR(80) |
VARCHAR2(80) |
— |
json |
JSONB |
JSON |
NVARCHAR(MAX) |
CLOB |
native |
'' (empty string) |
'' |
'' |
'' |
NULL | '' |
upsert() |
yes | yes | yes (MERGE) |
yes (MERGE) |
not yet (clear error) |
update().include() of a composite relation |
yes | yes | yes | yes | yes (children are embedded) |
| composite children | own table | own table | own table | own table | embedded in the parent's document |
| push / fetch of columns | yes | yes | yes | yes | schemaless: only whether the collection exists |
column rename (previousMapping) |
RENAME COLUMN |
RENAME COLUMN |
sp_rename |
RENAME COLUMN |
— |
Types
- String without length: unbounded (
TEXT) only on PostgreSQL; on the other engines it isVARCHAR(80). Setlengthfor longer values, ordbTypein the property mapping. - json: objects and lists are written and read as such on every engine; the column type changes (see the table).
- dateTime: PostgreSQL writes it with milliseconds and offset, so a
timestamptz(3)column (dbType) keeps the exact instant. On the other engines the precision depends on the column type (DATETIMEkeeps at least the seconds). - Empty string:
'',0andfalseare values, never NULL. Oracle is the exception: it has no empty string and stores''as NULL, so a value written as''comes back asnulland a filterp.email == ""finds nothing.
See Property types.
Writes
updateanddeletereturn the number of affected rows on every engine.upsert()usesON CONFLICT … DO UPDATEon PostgreSQL,ON DUPLICATE KEY UPDATEon MySQL and MariaDB, andMERGEon SQL Server and Oracle (from @lambdaorm/lib 3.5.0). On MongoDB it fails with a "not supported yet" error.update().include()of a composite relation inserts, updates and deletes the children with upsert, so it has the same support. On MongoDB the composite children are embedded in the parent's document, so the update replaces them there.
Stage commands
pushandfetchcompare tables and columns on every SQL engine.- MongoDB is schemaless:
fetchonly says whether each collection exists, and its fields are whatever its documents have.
Transactions
- On every SQL engine a transaction uses one connection per source and commits or rolls back source by source (there is no two-phase commit).
- MongoDB transactions need a replica set.