Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
README.md | 2025-08-13 | 4.6 kB | |
v0.40.0 source code.tar.gz | 2025-08-13 | 632.3 kB | |
v0.40.0 source code.zip | 2025-08-13 | 825.9 kB | |
Totals: 3 Items | 1.5 MB | 0 |
Highlights
Code generation is now modular and depends on plugins.
See the plugins configuration documentation to understand how to choose what is generated..
Added
- Made code generation modular by relying on built-in plugins that can be enabled or disabled in the configuration.
dbinfo
: Generates code for information about each database. Schemas, tables, columns, indexes, primary keys, foreign keys, unique constraints, and check constraints.enums
: Generates code for enums in a separate package, if there are any present.models
: Generates code for models. Depends onenums
.factory
: Generates code for factories. Depends onmodels
.dberrors
: Generates code for unique constraint errors. Depends onmodels
.where
: Generates type-safe code forWHERE
clauses in queries. Depends onmodels
.loaders
: Adds templates to themodels
package to generate code for loaders e.gmodels.SelectThenLoad.Table.Rel()
.joins
: Adds templates to themodels
package to generate code for joins e.gmodels.SelectJoin.Table.LeftJoin.Rel
.queries
: Generates code for queries.- Added new
types.Uint64
type that sends values to the database as strings. This is necessary because usinguint64
directly can cause an overflow if the value exceeds the maximum value of anint64
. This is a limitation imposed bydatabase/sql/driver.Valuer
interface. - Added support for
pgvector
types during code generation. pgvector.Vector
pgvector.HalfVector
pgvector.SparseVector
Changed
- Enums are now imported directly from a new generated
enums
package. This makes it easier to use enums in other packages without having to depend on themodels
package. - Preload functions now take a custom
orm.PreloadRel
struct instead of reusingorm.Relationship
. - By default, factories are now generated in
./factory
instead of./models/factory
. - Outputs are now determined by plugins which can be enabled or disabled in the configuration.
- UniqueConstraintErrors are now generated in a separate
dberrors
package instead of being generated in themodels
package. - Tests in the generated
models
package are no longer generated in a separatemodels_test
package. There is no longer any circular dependency since tests for the unique constraint errors are generated in thedberrors
package. orm.Columns
has been moved toexpr.ColumnsExpr
.orm.NewColumns
has been moved toexpr.NewColumnsExpr
.<Table>.Columns()
is removed. The columns expression is now expected to be embedded in theColumns
field of the<Table>
struct.<dialect>.View
and<dialect>.Table
now take an additional type parameter for the columns type. This is assigned to theColumns
field withNewView/NewTable
functions.
Removed
- Removed the
no_factory
configuration option. It is now replaced with thefactory
plugin which can be enabled or disabled. See https://bob.stephenafamo.com/docs/code-generation/configuration#plugins-configuration for more details. - Removed the
Only
andExcept
exported functions inorm
. They are now in the privateinternal
package. - Removed the generated
models.<Model>Columns
global variable. It can now be accessed throughmodels.<Table>.Columns
. - Removed the generated
models.TableNames
andmodels.ColumnNames
global variables. Their use can be replaced with thedbinfo
plugin which generates adbinfo
package with all the information about the database.
Fixed
- Fixed issue with redundant title casing column names in query templates. (thanks @luiscleto)
- Fix invalid expression with pointer-based type systems. (thanks @tak848)
- Fix panic when parsing SQLite
UPDATE
queries that do not contain aFROM
clause. - Fix issue when using enums in generated queries.
- Fix randomization of floats and decimals in the factory.
- Fix JSON data being incorrectly hex-encoded as bytea when using pgx through simple protocol, causing PostgreSQL to reject it with invalid input syntax errors. (by @Maxitosh)
- Fix issue with preload queries not using a defined schema on the related tables
New Contributors
- @tak848 made their first contribution in https://github.com/stephenafamo/bob/pull/520
- @Maxitosh made their first contribution in https://github.com/stephenafamo/bob/pull/530
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.39.0...v0.40.0