Download Latest Version v0.41.1 source code.tar.gz (636.0 kB)
Email in envelope

Get an email when there's a new version of Bob

Home / v0.40.0
Name Modified Size InfoDownloads / 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 on enums.
  • factory: Generates code for factories. Depends on models.
  • dberrors: Generates code for unique constraint errors. Depends on models.
  • where: Generates type-safe code for WHERE clauses in queries. Depends on models.
  • loaders: Adds templates to the models package to generate code for loaders e.g models.SelectThenLoad.Table.Rel().
  • joins: Adds templates to the models package to generate code for joins e.g models.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 using uint64 directly can cause an overflow if the value exceeds the maximum value of an int64. This is a limitation imposed by database/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 the models package.
  • Preload functions now take a custom orm.PreloadRel struct instead of reusing orm.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 the models package.
  • Tests in the generated models package are no longer generated in a separate models_test package. There is no longer any circular dependency since tests for the unique constraint errors are generated in the dberrors package.
  • orm.Columns has been moved to expr.ColumnsExpr.
  • orm.NewColumns has been moved to expr.NewColumnsExpr.
  • <Table>.Columns() is removed. The columns expression is now expected to be embedded in the Columns field of the <Table> struct.
  • <dialect>.View and <dialect>.Table now take an additional type parameter for the columns type. This is assigned to the Columns field with NewView/NewTable functions.

Removed

  • Removed the no_factory configuration option. It is now replaced with the factory plugin which can be enabled or disabled. See https://bob.stephenafamo.com/docs/code-generation/configuration#plugins-configuration for more details.
  • Removed the Only and Except exported functions in orm. They are now in the private internal package.
  • Removed the generated models.<Model>Columns global variable. It can now be accessed through models.<Table>.Columns.
  • Removed the generated models.TableNames and models.ColumnNames global variables. Their use can be replaced with the dbinfo plugin which generates a dbinfo 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 a FROM 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

Full Changelog: https://github.com/stephenafamo/bob/compare/v0.39.0...v0.40.0

Source: README.md, updated 2025-08-13