v0.35.0
Added
- Added support to generate code for
SELECT
,INSERT
,UPDATE
andDELETE
queries inbobgen-mysql
. - Added support to generate code for
INSERT
,UPDATE
andDELETE
queries inbobgen-sqlite
. - Added
LIMIT
andOFFSET
to the SQLite Update and Delete queries. - Added
IndexedBy
andNotIndexed
mods to the SQLite Delete queries. - Added the
Transactor
andTransaction
interfaces. - Added the
SeparatePackageForTests
attribute to generation outputs to indicate if generated tests should have their own package. - Added the
RandomColumnNotNull
mod to factories to generate random values for non-nullable columns without the chance of being null. - Added the
WithOneRelations
mod to factories to include every relation for a factory template. - Added
clause.TableRef
which mergesclause.Table
andclause.From
since they had overlapping functionality. - Added
RunInTx
method tobob.DB
. This starts a transaction and calls the given function with this transaction. - Add support for MySQL to
bobgen-sql
. - Added
Exec
test for generated queries that do not return rows. - Added
OrderCombined
,LimitCombined
,OffsetCombined
mods to MySQLSELECT
queries. These are applied to the result of aUNION
,INTERSECT
orEXCEPT
query. - Added
type_limits
property to column definitions. - Added
limits
option torandom_expr
function for types. This is to pass any column limits to the randomization function (e.g.max_length
for strings). - Added tests to check that the generated factory can create models and save into the database.
- Added the
pgtypes.Snapshot
type for thepg_snapshot
andtxid_snapshot
type in PostgreSQL. - Added a custom
Time
type to thetypes
package. This is motivated by the fact that thelibsql
driver does not support thetime.Time
type properly. - Added an option to disable aliasing when expressing
orm.Columns
. Also addedEnableAlias
andDisableAlias
methods toorm.Columns
to control this behavior. - Added a
PrimaryKey
method to{dialect}.Table
to get the primary key columns of the table.
Changed
-
Changed the INDEXED BY and NOT INDEXED mods for SQLite update queries from
TableIndexedBy
andTableNotIndexed
toIndexedBy
andNotIndexed
. -
Use
LIBSQL_TEST_SERVER
environment variable to run tests against a libSQL server instead of the hardcodedlocalhost:8080
. -
BeginTx
now returns aTransaction
interface instead of abob.Tx
. -
Generated tests that required a database connection no longer create a new connection for each test. Instead it depends on a
testDB
connection that the user has to provide. -
In the generated models, relationships for
ModelSlice
are now loaded using arrays to reduce the number of parameter in the query.-- Before SELECT * FROM pilots WHERE jet_id IN ($1, $2, $3, ...); -- Parameters increase with the number of pilots -- After SELECT * FROM pilots WHERE jet_id IN (SELECT unnest(CAST($1 AS integer[])); -- Parameters are always 1
-
In the generated model code,
Preload
is now a struct instead of multiple standaalone functions.
It is now used likePreload.User.Pilots()
, instead ofPreloadUserPilots()
. -
In the generated model code,
ThenLoad
is now a struct and has been split for each query type.
It is now used likeSelectThenLoad.User.Pilots()
, instead ofThenLoadUserPilots()
. -
In the generated model code, the Load interfaces no longer include the name of the source model since it is a method on the model.
It now looks like*models.User.LoadPilots
instead of*models.User.LoadUserPilots
. -
Made changes to better support generating code in multiple languages.
-
Mark queries with
ON DUPLICATE KEY UPDATE
as unretrievable in MySQL. -
Unretrievable
INSERT
queries usingOne, All, Cursor
now immediately returnorm.ErrCannotRetrieveRow
instead of executing the query first. -
Generated tests are now run when testing drivers.
-
MEDIUMINT
andMEDIUMINT UNSIGNED
are now generated asint16
anduint16
respectively. This is because Go doe not support 24 bit integers. -
The randomization function for floats, strings, and decimals now respect the limits set in the column definition.
-
txid_snapshot
is now generated aspgtypes.Snapshot
instead ofpgtypes.TxIDSnapshot
. -
cidr
postgres type is now generated astypes.Text[netip.Prefix]
instead oftypes.Text[netip.Addr]
. -
money
postgres type is now generated as a string with a custom randomization expression instead of a decimal. -
Factory template mods now take a context argument. This allows for more control when using recursive mods.
-
Removed
WithOneRelations
mod from factories, now replaced withWithParentsCascading
which also includes parents for any parent relationships.
Removed
- Removed
clause.Table
andclause.From
, and merge intoclause.TableRef
since they had overlapping functionality. - Remove unnecessary context closure in generated join helpers.
- Remove the deprecated
wipe
generation option. - Remove
pgtypes.TxIDSnapshot
type. This is now replaced withpgtypes.Snapshot
.
Fixed
- Use correct row name for generated queries in
bobgen-sqlite
. - Properly select query comment in
bobgen-sqlite
. - Fixed issue with using generated queries with
VALUES
as mods. - Moved
Partitions
in MySQL delete queries to after the table alias. - Fixed issue with inserting into a table with all rows having default values in SQLite.
- Use table name and not table alias in SQLite returning clause since the alias is not available in the
RETURNING
clause. - Fixed generated unique constraint errors for SQLite.
- Correctly resuse inserted rows in factories.
Full Changelog: v0.34.2...v0.35.0