Skip to content

v0.37.0

Compare
Choose a tag to compare
@stephenafamo stephenafamo released this 31 May 10:01
· 27 commits to main since this release

Highlights

  1. Nullable columns are no longer generated as github.com/aarondl/opt/null.Val[T], but as database/sql.Null[T].
  2. Optional fields (e.g. in setters) are no longer generated as github.com/aarondl/opt/omit.Val[T] but as pointers.

Unfortunately, this will require a lot of changes to existing code that depends on the previously generated types.
However, I believe this is a better direction as it uses only the standard library.

Added

  • Added the drivers/pgx package which contains types and functions to use a pgx/v5 connection as a bob.Executor.
  • Added support for github.com/ncruces/go-sqlite3. (thanks @ncruces)
  • Added support for configuring what type to generate specific null versions of a type instead of always wrapping with sql.Null[T].

Changed

  • The bob.Transaction interface now takes a context.Context argument in the Commit and Rollback methods.
  • The method BeginTx on the bob.Transaction interface is now changed to Begin and it takes a single context argument.
    This is to make it easier to implement for non database/sql drivers.
  • In the generated model, the PrimaryKeyVals() method is now private.
  • Renamed driver_name to driver in code generation configuration.
  • In type replacements, nullability is not used in matching.
    Previously, nullability of matches was set to false by default, and would require an additional replacement to also match nullable columns.

Removed

  • Removed the New and NewQueryer functions. Any of bob.NewDB, bob.NewTx or bob.NewConn can be used instead.
  • Removed the StdInterface interface as it is unnecessary.
  • Remove redundant orm.Model interface.
  • Remove dependence on github.com/aarondl/opt in generated code.
    • Nullable values are now wrapped database/sql.Null with instead of github.com/aarondl/opt/null.Val.
    • Optional values are now represented as pointers instead of github.com/aarondl/opt/omit.Val[T].
  • Removed in_generated_package type configuration option. This was limited and could only indicate that the type is in the models package.
    Instead the full import path can now be used in the imports configuration option, and if it is in the same package as the generated code, the prefix will be automatically removed.

Fixed

  • Properly handle nil args when checking if default or null in mysql table insert query.
  • Fix bug in querying slice relationships in MySQL and SQLite.

New Contributors

Full Changelog: v0.36.1...v0.37.0