Added
-
Add PreloadAs PreloadOption to override the join alias when preloading a relationship with a left join. (thanks @daddz)
-
Add
AliasedAs()method totableColumnsandtableWheretypes 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
fmmods 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,CreateOrFailandCreateManyOrFailmethods 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 onViewsto 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.Addrinstead ofnetip.Prefixfor Postgrescidrtype. -
Use
decimal.Decimalinstead ofstringfor Postgresmoneytype. -
Use
net.HardwareAddrfor Postgresmacaddr8type, in addition to themacaddrtype. -
Code generation now generates struct tags for the generated model Setters as well, if configured through the
Tagsconfiguration option. Previoulsy, only the model struct fields were tagged. (thanks @singhsays)
Removed
- Remove
TableWherefunction from the generated code. It was not used by the rest of the generated code and offered no clear benefit. - Removed
Asstarter. It takes anExpressionand is not needed since theExpressionhas anAsmethod 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