SQL query builder and ORM/Factory generator for Go with support for PostgreSQL, MySQL and SQLite
MIT License
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.28.0...v0.28.1
Published by stephenafamo 4 months ago
pgtypes.Inet
for inet
type in PostgreSQL. (thanks @gstarikov)pgtypes.Macaddr
for macaddr
and macaddr8
types in PostgreSQL.pgtypes.LSN
type for the pg_lsn
type in PostgreSQL.pgtypes.TxIDSnapshot
type for the txid_snapshot
type in PostgreSQL.pgtypes.TSVector
type for the tsvector
type in PostgreSQL.AliasOf
property to codegen type definitions to allow for defining types that have their own randomization logic.DependsOn
property to codegen type definitions to allow for defining types that depend on other types. This ensures that necessary code for the dependent types is generated.xml
type definition for custom randomization logic.Cast()
starter to all dialects to build CAST(expr AS type)
expressions.parray
package to pgtypes
.HStore
to the pgtypes
package.DebugPrinter
now prints args a bit more nicely by using thier Value()
method if they implement the driver.Valuer
interface.types.Stringer[T]
. It makes assumptions for how the type should be scanned and is not reliable.FROM
clause to SELECT
queries that are used as subqueries.Full Changelog: https://github.com/stephenafamo/bob/compare/v0.27.1...v0.28.0
Published by stephenafamo 5 months ago
Count()
queries not removing the offset from the original query. (thanks @daddz)Full Changelog: https://github.com/stephenafamo/bob/compare/v0.27.0...v0.27.1
Published by stephenafamo 5 months ago
Add PreloadAs PreloadOption to override the join alias when preloading a relationship with a left join. (thanks @daddz)
Add AliasedAs()
method to tableColumns
and tableWhere
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
and CreateManyOrFail
methods to generated factory Templates
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 on Views
to clone the query instead of changing the existing one. This makes queries reusable and the Count()
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 of netip.Prefix
for Postgres cidr
type.
Use decimal.Decimal
instead of string
for Postgres money
type.
Use net.HardwareAddr
for Postgres macaddr8
type, in addition to the macaddr
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)
TableWhere
function from the generated code. It was not used by the rest of the generated code and offered no clear benefit.As
starter. It takes an Expression
and is not needed since the Expression
has an As
method which can be used directly.types.Stringer[T]
where the wrong value was returned in the Value()
method.Full Changelog: https://github.com/stephenafamo/bob/compare/v0.26.1...v0.27.0
Published by stephenafamo 5 months ago
netip.Prefix
instead of netip.Addr
for postgres inet column type. This makes it possible to contain a subnet. By @stephenafamo in https://github.com/stephenafamo/bob/pull/217
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.26.0...v0.26.1
Published by stephenafamo 5 months ago
bobgen-sql
a code generation driver for SQL schema files. Supports PostgreSQL and SQLite.compare_expr
and compare_expr_imports
to the types
configuration. This is used when comparing primary keys and in testing.never_required
to relationships configuration. This makes sure the factories does not require the relationship to be set. Useful if you're not using foreign keys. (thanks @jacobmolby)types
configuration.fmt.Stringer
, encoding.TextMarshaler
, encoding.TextUnmarshaler
, encoding.BinaryMarshaler
and encoding.BinaryUnmarshaler
interfaces.OVER ()
with an empty window definition in PostgreSQL. (thanks @relvacode)GROUP BY
to NULL
if there are no expressions to group by.Full Changelog: https://github.com/stephenafamo/bob/compare/v0.25.0...v0.26.0
Published by stephenafamo 9 months ago
github.com/jaswdr/faker
dependency from v1
to v2
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.24.0...v0.25.0
Published by stephenafamo 9 months ago
gofumpt
replacements
configuration is now a string referring to the type defined in the types
configuration.Imports
from column definition.INTEGER
columns are now correctly generated as int32
not int
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.23.2...v0.24.0
Published by stephenafamo 10 months ago
modify
for relationships with no primary keysql.ErrNoRows
when Insert/Upsert returns nothingFull Changelog: https://github.com/stephenafamo/bob/compare/v0.23.1...v0.23.2
Published by stephenafamo 10 months ago
Setter.Expressions()
in parenthesisFull Changelog: https://github.com/stephenafamo/bob/compare/v0.23.0...v0.23.1
Published by stephenafamo 10 months ago
bob.Cache()
which saves the built SQL and args to prevent rebuilding the same query multiple times.As()
starter to alias expressionsOP()
builder method for using custom operatorstable.InsertQ(ctx, db)
now includes the insert columns from the table model.um.SetCol()
which maintains the old behavior of um.Set()
.Expressions()
method for Setters to make it easier to use them in um.Set()
or im.Set()
.table
keyfrom_unique
, to_unique
, key_nullable
can no longer be configured. They are now inferred from the database.to_key
has been changed to modify
and should be set to from
, to
or ""
to indicate which side of the relationship to modify.RelWhere.Value
is now RelWhere.SQLValue
um.Set()
to take a list of expressions.Insert()
to InsertMod()
to avoid confusion.JOIN USING
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.22.0...v0.23.0
Published by stephenafamo about 1 year ago
InsertQ
, UpdateQ
, and DeleteQ
methods to Table models to start INSERT, UPDATE and DELETE queries respectively.WhereOr
and WhereAnd
to make it easier to combine multiple generated where clausesExec()
method of view queries instead of sql.Result
Expression
instead of any
orm.Table
and orm.Setter
interfaces.TablesInfo
method and make sure we don't exclude entire table when targeting columns (thanks @jacobmolby)Full Changelog: https://github.com/stephenafamo/bob/compare/v0.21.1...v0.22.0
Published by stephenafamo over 1 year ago
Upsert
and UpsertAll
methods of mysql.Table
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.21.0...v0.21.1
Published by stephenafamo over 1 year ago
psql
driverFull Changelog: https://github.com/stephenafamo/bob/compare/v0.20.6...v0.21.0
Published by stephenafamo over 1 year ago
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.20.5...v0.20.6
Published by stephenafamo over 1 year ago
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.20.4...v0.20.5
Published by stephenafamo over 1 year ago
huandu/go-clone
with qdm12/reprint
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.20.3...v0.20.4
Published by stephenafamo over 1 year ago
jinzhu/copier
with huandu/go-clone
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.20.2...v0.20.3
Published by stephenafamo over 1 year ago
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.20.1...v0.20.2
Published by stephenafamo over 1 year ago
github.com/gofrs/uuid/v5
Full Changelog: https://github.com/stephenafamo/bob/compare/v0.20.0...v0.20.1