// the find
uptrace/bun
SQL-first Golang ORM
Bun is a SQL-first ORM for Go that builds queries programmatically while keeping SQL concepts front and center — you're writing CTEs, not fighting an abstraction that hides them. It targets developers who want type safety and struct scanning without surrendering control over what SQL actually executes. Works across PostgreSQL, MySQL, SQLite, MSSQL, and Oracle from a single API.
The query builder maps almost 1:1 to SQL constructs — CTEs, window functions, and raw expressions are first-class, not bolted on. The hook system (query hooks for OTel, debug logging, New Relic) is clean and composable without touching model code. The multi-module layout per dialect means you don't pull in MySQL's driver when you only need Postgres. Fixture support via YAML plus a proper migration system with up/down functions means it covers the full dev workflow, not just runtime queries.
The multi-module monorepo is a maintenance burden: each dialect, driver, and extra package has its own go.mod, so a cross-cutting change (like updating a dependency) means touching a dozen modules and go.sum files. Relation loading does N+1 queries under the hood — there's no join-based eager loading, just separate SELECT IN queries per relation, which will hurt at scale if you're not aware of it. Oracle support is a community dialect and visibly less tested than the Postgres path; don't assume parity. The migration system is functional but minimal — no squashing, no baseline detection, no locking beyond what your DB provides, so teams with complex schema histories will hit its ceiling.