Comparison
An honest, row-by-row comparison of fusion-orm against gorm and bun — capabilities, ergonomics, and measured overhead.
fusion-orm borrows deliberately from both sides: gorm's fluent chaining and
callback pipeline, bun's SQL-first query engine. The tables below state
what each project actually ships; where fusion-orm lacks something, it is
marked rather than papered over. The performance row cites fusion's
measured benchmarks (CHANGELOG.md:50-54); for the other two projects,
consult their own numbers.
Legend
✅ shipped natively · ⚠️ available in a different shape or partially ·
❌ not available. Each cell is backed by the repository source or the
README comparison table (README.md:109-122).
fusion-orm vs gorm
| Row | fusion-orm | gorm |
|---|---|---|
| API style | Fluent chain + SQL-first clauses | Fluent chain + callbacks |
| Generics facade | fusion.G[T] with checked chain and finisher interfaces | gorm.G[T] (v1.25+) |
| Dialects shipped | SQLite, PostgreSQL | SQLite, PostgreSQL, MySQL, MSSQL, ClickHouse |
| Batched preload | ✅ one query per relation, nested, apply functions | ✅ Preload |
| Inline relation joins | ✅ Joins("Profile") with dotted-column scan | ✅ Joins |
| Association API | ✅ Find/Append/Replace/Delete/Clear/Count | ✅ Association |
| Soft delete | ✅ fusion.DeletedAt embed, Unscoped, Restore | ✅ gorm.DeletedAt, Unscoped |
| Prepared statements | ✅ LRU+TTL cache built in | ⚠️ config option (PrepareStmt) |
| Error sentinels | ✅ errors.Is throughout, constraint translation | ✅ gorm.Err* + translated duplicates |
| Migrations | ✅ AutoMigrate + versioned Go and numbered SQL migrations in-tree | ⚠️ AutoMigrate (Go migrations are third-party) |
| Query hooks | ✅ QueryHook + SlogQueryHook adapter | ✅ callbacks + plugins |
| Feature flags | ✅ explicit capability bitset per dialect | ⚠️ per-dialect branches |
| Performance (allocs/op geomean, in-memory SQLite) | 97 | 249 |
| License | MIT | MIT |
What gorm has that fusion-orm does not
gorm's ecosystem is far larger: DBResolver (read/write splitting),
Sharding, Hints, Gen (code generation), a first-party Prometheus
plugin, MySQL and MSSQL dialects, and session-level single-table
inheritance patterns. fusion-orm ships none of these — see
migrating from gorm for the exact gap
list.
fusion-orm vs bun
| Row | fusion-orm | bun |
|---|---|---|
| API style | Fluent chain + SQL-first clauses | Query builder + hooks |
| Generics facade | fusion.G[T] with checked chain and finisher interfaces | ⚠️ generic model helpers (bun.NewSelectModel-style) |
| Dialects shipped | SQLite, PostgreSQL | SQLite, PostgreSQL, MySQL, MSSQL |
| Batched preload | ✅ one query per relation (Preload) | ✅ with relation loading |
| Inline relation joins | ✅ Joins("Profile") with dotted-column scan | ✅ q.Join |
| Association API | ✅ Find/Append/Replace/Delete/Clear/Count | ⚠️ relation helpers |
| Soft delete | ✅ fusion.DeletedAt embed, Unscoped, Restore | ⚠️ soft_delete field option |
| Prepared statements | ✅ LRU+TTL cache built in | ⚠️ connection-level prepared statements |
| Error sentinels | ✅ errors.Is throughout, constraint translation | ⚠️ dialect-specific errors |
| Migrations | ✅ AutoMigrate + versioned Go/SQL in-tree | ⚠️ separate bun/migrate package |
| Query hooks | ✅ QueryHook + SlogQueryHook adapter | ✅ QueryHook (same Before/After shape) |
| Feature flags | ✅ explicit capability bitset per dialect | ⚠️ per-dialect switches |
| Performance (allocs/op geomean, in-memory SQLite) | 97 | 126 |
| License | MIT | MIT |
What bun has that fusion-orm does not
bun ships MySQL and MSSQL dialects, a fixtures package (bun/dbfixture),
and a standalone expression builder (NewRaw) usable apart from a model.
fusion-orm focuses on SQLite and PostgreSQL only, and builds expressions
through clauses on a *DB chain — see
migrating from bun.
How to read the dialect rows
The dialect count matters more than the preload row suggests. fusion-orm's
query builders branch on a capability bitset (dialect/feature), not
on dialect-name strings, which keeps SQLite and PostgreSQL cheap to
support correctly — but a third dialect means declaring its feature set,
not just writing a name. That is why the list is short and correct.
Row-by-row notes
A few rows deserve their evidence spelled out.
Association API. fusion's db.Association("Posts") object exposes the
six verbs as first-class methods with errors reported through them
(association.go:24):
func (a *Association) Find(dest any) errorAppend, Replace, Delete, Clear, and Count complete the set
(association.go:104-418). gorm's Association is the same shape; bun's
relation helpers hang off the query builder rather than an object — hence
the ⚠️.
Prepared statements. fusion wraps the connection pool itself, so every
statement — including ones from transactions — goes through the cache
(fusion.go:206-208):
if config.PrepareStmt {
config.ConnPool = newPreparedPool(config.ConnPool, config.PreparedStmtCacheSize, config.PreparedStmtTTL)
}gorm's PrepareStmt is a config option over the same idea; bun's caching
sits at the driver/connection level — different placement, hence ⚠️ on
both.
Migrations. fusion ships one runner: AutoMigrate for inspect/diff
plus Register/Up/Down for versioned Go migrations and
LoadSQLFiles for numbered SQL pairs, guarded by a lock table
(migrator/migrator.go:621-626, migrator/migrator.go:694). bun's
versioned migrations live in a separate bun/migrate module with its own
runner; gorm ships AutoMigrate only — versioned Go migrations are
third-party plugins. Hence ⚠️ on both.
Feature flags. The bitset is explicit and nameable, so dialect
capabilities read like a table, not a stack of if statements:
{RowValues, "RowValues"},When to choose fusion-orm
- You want gorm's API shape —
Model/Where/First/Create/Updates, callbacks, base models — over a bun-style engine with allocation discipline. - You need built-in migrations (
AutoMigrateplus versioned Go and numbered SQL migrations with a lock table) and built-in prepared statements without third-party plugins. - Your databases are SQLite and/or PostgreSQL — the two dialects are exhaustively tested, including golden SQL checks in CI.
- You want every failure branchable through
errors.Issentinels, and guardrails like the missing-WHERE guard switched on by default.
When to choose gorm
- You need the plugin ecosystem:
DBResolver,Sharding,Hints,Gen, Prometheus, and the large third-party plugin catalog. - You must run on MySQL, MSSQL, or ClickHouse.
- Your team already has deep gorm experience and migration tooling built around it.
When to choose bun
- You want SQL-builder-first control — composing selects, CTEs, and expressions by hand — with hooks around execution.
- You need MySQL, MSSQL, or fixtures-based testing (
bun/dbfixture). - You prefer an explicit
ctxon every call and aRunInTxhelper over a session-based context.
Where next
Migrating from gorm
Tag aliases, API parity, and the exact behavior differences.
Migrating from bun
Tag mapping, builder-to-chain translation, hooks, and transactions.
Performance
Where the allocation numbers come from, and how to reproduce them.
Dialects
The feature-bitset model behind the dialect rows above.