Releases: stephenafamo/bob
v0.20.2
- Account for windows when calculating models module path
Full Changelog: v0.20.1...v0.20.2
v0.20.1
- Update the generated code to use
github.com/gofrs/uuid/v5
- Fix bug where auto-increment columns were marked as generated in the SQLite driver
Full Changelog: v0.20.0...v0.20.1
v0.20.0
Full Changelog: v0.19.1...v0.20.0
Added
- Add the
PreloadWhere
preload mod to filter what relation should be preloaded. ViewQuery
now embedsbob.BaseQuery
giving it additional methods likeApply
andBuild
- Add plugin support. Currently 3 plugin hooks are provided.
PlugState
,PlugDBInfo
andPlugTemplateData
.
Changed
- Make
View.Name()
return a dialect-specific expression - Improve
Debug
helpers.Debug
writes query output to stdoutDebugToWriter
writes the query output to anyio.Writer
with a fallback to stdout.DebugToPrinter
prints the query with a givenbob.DebugPrinter
. Also falls back to stdout.
- Rename
OnlyColumns
toPreloadOnly
andExceptColumns
toPreloadExcept
to be more consistent with the newly addedPreloadWhere
. JoinChain.On
now takes Expressions instead ofany
.JoinChain.Using
now takes strings instead ofany
.- Export
gen.TemplateData
Removed
- Remove
ILIKE
operator from MySQL since it is not supported. - Removed
Destination()
method in driver interface. - Removed
PackageName()
method in driver interface.
Fixed
- Account for possible clashes between column and relationship alias
- Make
Preload
mods work the same way as other query mods - Avoid overwriting manually flipped relationships.
- Account for potentially null relationship in Load methods
v0.19.1
- Fix
On
method for JoinChain inmysql
andsqlite
Full Changelog: v0.19.0...v0.19.1
v0.19.0
Added
- Add
LIKE
andILIKE
operators - Print generated files
- Add
no_reverse
option for user-configured relationships
Changed
- Move common parts of loading to shared internal package
Fixed
- Fix generated joins for multi-sided relationships
Full Changelog: v0.18.2...v0.19.0
v0.18.2
- Account for relationships with tables that do not have a primary key in models and factories
- Properly extract preloaders nested in mods.QueryMods
- Fix bug in preloading with multiple sides
- Fix issue with multi-sided relationships that include views
Full Changelog: v0.18.1...v0.18.2
v0.18.1
- Make self-referencing foreign keys work
- Tweak factory types to make collisions even less likely
Full Changelog: v0.18.0...v0.18.1
v0.18.0
Breaking Changes in v0.18.0
Comparison methods now require an expression (bob.Expression
)
The primary breaking change is that several builder methods now require a bob.Expression
instead of any
.
While this makes building some simple queries more verbose, it makes it harder to make some errors.
As an example, consider the following query
// SELECT * FROM users WHERE id = 1
psql.Select(
sm.From("users"),
sm.Where(psql.X("id").EQ(1)),
)
This feels like the natural way to build this query, however there are some subtle potential issues:
-
1
should probably be passed as an argument. In a real world application, this could lead to an SQL injection.// SELECT * FROM users WHERE id = $1 psql.Select( sm.From("users"), sm.Where(psql.X("id").EQ(psql.Arg(1))), )
-
This query will throw an error if we use a string
// !!!!INVALID QUERY!!!! // SELECT * FROM users WHERE name = Stephen psql.Select( sm.From("users"), sm.Where(psql.X("name").EQ("Stephen")), )
The initial reason why these took any
was to make Bob easy to adopt. However, after using this in practice, it is likely that the user always wants to do something to make it an expression.
- If it is a table or column name, it should probably be quoted with
psql.Quote
- If it is an argument, it should be passed with
psql.Arg
No more X
builder
The X
builder, while convenient doesn't quite fit in anywhere. Most queries will be started with a quote, and can then be fluently chained with other expressions.
In the interest of keeping the surface area of this pacakge small, I've decided to remove it until there is a concrete need.
No more P
builder method
The P
builder method was for adding parentheses to a single expression. However, this overlaps with the Group
method with adds parentheses around a list of expressions separated with a comma.
Since using the Group
method with a single expression does the same thing as the P
method, the P
method now feels redundant.
v0.17.3
- Fix bug with args in table updates
- Fix some typos in documentation (thanks @leonardtan13)
v0.17.2
- Fix a bug when multiple multi-column foreign keys exist
- Multiple internal changes to the generator to make it easier to write a custom entrypoint
- More robust testing of code generation
- json, yaml and toml struct tags are no longer autogenerated but can still be added though configuration