docs/Databases/FerretDB/1/Conformance.md
FerretDB v1 translates one MongoDB query into five different SQL dialects. That
{n: {$gt: 5}} runs on PostgreSQL, MySQL, MariaDB and SAP HANA says very
little; whether it returns the same documents, in the same order as on SQLite
is the question that decides whether a backend can be trusted with a board.
./build.sh # -> Tests -> All databases (sequential)
./releases/db-conformance.sh # the same thing, without the menu
build.bat has the same entry on Windows (it runs the same script through bash).
FerretDB subdirectory is not
there it is cloned from [email protected]:wekan/FerretDB (falling back to
HTTPS), then updated, then built through its own build.sh, which installs
the Go toolchain and the module dependencies if they are missing. The tests
run against that binary — the newest code — not a downloaded release.docker manifest inspect
is asked whether the image has a build for this architecture, so the answer
stays true as images change. On arm64 that is SQLite, PostgreSQL, MySQL and
MariaDB; on ppc64le and s390x, SQLite, PostgreSQL and MariaDB; on riscv64,
SQLite and PostgreSQL.One catalogue of 100 cases in 15 groups, taken from FerretDB v1's own source rather than from MongoDB's manual — the point is to cover what this FerretDB implements:
$slice and $elemMatch), sorting, skip/limit;count, distinct;$match, $group with every accumulator, $project,
$addFields, $facet, $bucket, $lookup, $replaceRoot, $sortByCount;findAndModify, replaceOne, the delete commands;explain, collStats, dbStats, listCollections, buildInfo.The seed data is deliberately awkward: a null, a missing field, a negative number, a zero, an empty array, an array of documents, mixed-case strings. Tidy data lets a broken translation pass.
Answers are normalised — types spelled out, key order sorted — and compared byte for byte, so document order counts: a sort that returns the right documents in a different order is a difference, not a detail.
Three cases are compared more loosely, and they say so in the report: an explain
plan is a different plan on every engine (only its shape is compared), and
collStats/dbStats are sizes a different storage engine is entitled to answer
differently (they only have to answer). Everything else must match exactly.
Two backends failing the same way is agreement about a limitation, not a difference. One answering where the other fails is a difference.
FerretDB listens on 37017 here, not 27017 — 27017 is where a dev server's database lives and where the compose files publish FerretDB, so binding it would either fail or, worse, point these tests at somebody else's database and rewrite it. The database server it starts is published on 35432 rather than its usual 5432/3306. Both defaults move on if something is already listening, and both can be set:
WEKAN_CONFORMANCE_PORT=47017 WEKAN_CONFORMANCE_DB_PORT=45432 ./releases/db-conformance.sh
Its containers are named per run (wekan-conformance-db-<datetime>), so a stack
started with docker compose up — whose containers are wekan-postgres,
wekan-ferretdb — is never stopped or reused by this.
../log/<datetime>/, with every other WeKan test run:
| File | What is in it |
|---|---|
db-conformance-build.log | Cloning, updating and building FerretDB |
db-conformance-<backend>.json | Every answer that backend gave |
db-conformance-<backend>.log | That backend's database and FerretDB output |
db-conformance-report.md | Where they agree, and every case where they do not |
db-conformance-summary.txt | One line per backend: ran, skipped, or why not |
The script exits non-zero when a backend disagrees with the reference.
Not run unless WEKAN_CONFORMANCE_HANA=1 is set. Its image is amd64-only, wants
~16 GB of RAM and tens of GB of disk, and needs SAP's licence accepted — not
something to start because somebody picked a menu entry.
tests/dbConformance/ — the catalogue, the runner and the comparison