Reference skill for github.com/stephenafamo/bob (v0.46.0): query builder, generated models/ORM, bobgen code generation, factories, and result scanning. SKILL.md routes to per-subsystem reference files (query-builder, models, code-generation, execution, comparisons). Symlinked into ~/.claude/skills and ~/.agents/skills (Codex). Verified with a RED/GREEN subagent test and cross-checked against v0.46.0 source (flat mod import paths, AppendHooks, plural table var, WhereMod ops). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2.6 KiB
2.6 KiB
Bob vs other Go SQL libraries
These comparisons are distilled from Bob's own
vs/docs, which are written by Bob's author. Treat the framing as informed but partial; the factual axes (codegen direction, migrations, dialect model) are accurate and what you'll usually decide on.
Bob's author also wrote SQLBoiler, and started Bob as "an experiment for how v5 of SQLBoiler could look." Bob is effectively SQLBoiler's successor with a clean foundation.
| Tool | Kind | Schema direction | Migrations | Type safety | Notes |
|---|---|---|---|---|---|
| Bob | Query builder + DB-first ORM | Database-first (introspect DB or .sql) |
Not included (use your own) | Full, compile-time | Per-dialect mods → can't build invalid SQL; factories; incremental adoption |
| GORM | Code-first ORM | Code → DB | Auto-migrate built in | Low (lots of interface{}, magic strings → runtime panics) |
Big ecosystem/plugins; weaker query builder; all-or-nothing adoption |
| Ent | Code-first ORM | Schema-as-Go-code → DB | Owns migrations (via Atlas) | Good | Mature ecosystem (gqlgen, gRPC); all-or-nothing; predicates less flexible than Bob for complex SQL |
| SQLBoiler | Query builder + DB-first ORM | Database-first | Not included | Good | Shares one query/mod type across all dialects → can assemble invalid queries; Bob is its descendant |
| Jet | Query builder only (explicitly not an ORM) | Database-first | Not included | Good | Similar build experience to Bob, but no relationship loading, no factories — every mapping is manual |
How to choose
- Want database-first + type safety + the ability to build any dialect-specific SQL, and you manage migrations yourself → Bob.
- Want the schema defined in Go and the tool to own migrations → Ent (typed) or GORM (looser).
- Only ever write raw SQL and just want typed functions → plain sqlc is simpler; Bob's Layer 4 does the same but pairs it with models/factories if you later want them.
- Want just a query builder, no ORM → Bob's Layer 1 or Jet. Bob adds an upgrade path to models.
What Bob deliberately omits
- Automatic
created_at/updated_at. Set these at the DB level (column defaults / triggers). - Soft deletes. Left out on purpose — cascading soft-deletes through relationships have too many edge cases. Implement explicitly if you need them.
What Bob added over SQLBoiler
Cross-schema generation, preloading via LEFT JOINs, multi-key relationships, has-one-through /
has-many-through, and context chaining through hooks.