v0.27.0
Added
-
Add PreloadAs PreloadOption to override the join alias when preloading a relationship with a left join. (thanks @daddz)
-
Add
AliasedAs()
method totableColumns
andtableWhere
types to use a custom alias. -
Add
AliasedAs()
method to generated relationship join mods. This is avaible in two places:-
one to change the alias of the table being queried
models.SelectJoins.Jets.AliasedAs("j").InnerJoin.Pilots(ctx)
-
and the other to change the alias of the relationship.
models.SelectJoins.Jets.InnerJoin.Pilots(ctx).AliasedAs("p")
-
-
Add
fm
mods to all supported dialects (psql, mysql and sqlite). These are mods for functions and are used to modify the function call. For example:// import "github.com/stephenafamo/bob/dialect/psql/fm" psql.F( "count", "*",)(fm.Filter(psql.Quote("status").EQ(psql.S("done"))))
-
Add
MustCreate
,MustCreateMany
,CreateOrFail
andCreateManyOrFail
methods to generated factory Templates
Changed
-
Change the function call point for generated relationship join mods. This reduces the amount of allocations and only does the work for the relationship being used.
// Before models.SelectJoins(ctx).Jets.InnerJoin.Pilots // After models.SelectJoins.Jets.InnerJoin.Pilots(ctx)
-
Changed the
Count()
function onViews
to clone the query instead of changing the existing one. This makes queries reusable and theCount()
function to behave as one would expect.// This now works as expected query := models.Jets.Query(ctx, db, /** list of various mods **/) count, err := query.Count() items, err := query.All()
-
Changed how functions are modified. Instead of chained methods, the
F()
starter now returns a function which can be called with mods:// Before psql.F( "count", "*",).FilterWhere(psql.Quote("status").EQ(psql.S("done"))), // After // import "github.com/stephenafamo/bob/dialect/psql/fm" psql.F( "count", "*",)(fm.Filter(psql.Quote("status").EQ(psql.S("done")))),
This makes it possible to support more queries.
-
Use
netip.Addr
instead ofnetip.Prefix
for Postgrescidr
type. -
Use
decimal.Decimal
instead ofstring
for Postgresmoney
type. -
Use
net.HardwareAddr
for Postgresmacaddr8
type, in addition to themacaddr
type. -
Code generation now generates struct tags for the generated model Setters as well, if configured through the
Tags
configuration option. Previoulsy, only the model struct fields were tagged. (thanks @singhsays)
Removed
- Remove
TableWhere
function from the generated code. It was not used by the rest of the generated code and offered no clear benefit. - Removed
As
starter. It takes anExpression
and is not needed since theExpression
has anAs
method which can be used directly.
Fixed
- Fix a bug with
types.Stringer[T]
where the wrong value was returned in theValue()
method.
New Contributors
- @daddz made their first contribution in #220
- @singhsays made their first contribution in #225
Full Changelog: v0.26.1...v0.27.0