v0.49.0
Added
- Added
bob.NextUniqueInt()for generating unique SQL alias suffixes (#719). (thanks @atzedus) - Code generation now emits a reflection-free
scan.Mapperper table (<table>ScanMapper) that scans each result column directly into the struct field by index. The mapper is passed to the model constructor, so every query built from a model —Query(), relationship loaders, andInsert/Update/DeletewithRETURNING— scans without the per-row reflection ofscan.StructMapper. (thanks @sandonemaki) - Generated
Wherestructs now include relationship filters under anRfield (e.g.SelectWhere.Pilots.R.HasJets(filters ...bob.Mod[*dialect.SelectQuery])) that filter rows by the existence of related rows, using a correlatedEXISTSsubquery (semi-join) built from the schema's relationship definitions. TheRnamespace mirrors the model struct and keeps the filters from colliding with column names. Unlike filtering throughSelectJoins, this does not multiply parent rows, soDISTINCTis not needed andCount()/LIMIT-based pagination stay correct (#722). (thanks @sandonemaki)
Changed
NewViewxandNewTablexin thepsql,mysqlandsqlitedialects now take ascan.Mapper[T]argument used for all queries built from the view/table. Passnilto keep the previous reflection-basedscan.StructMapperbehaviour.NewView/NewTableare unchanged. (thanks @sandonemaki)- JOIN a DISTINCT unnest(...) for composite-key relationship loaders & counts on PostgreSQL. (thanks @sandonemaki)
Fixed
- Fixed an unused type import (e.g.
github.com/google/uuid) in generated models when the type is only referenced through optional wrapper expressions, such as m2m relationship helpers for a join table with auuidcolumn (#730). - Fixed the counts plugin's generated
Cfield reusing therelation_tagstruct tag, which collided with the relationsRfield and causedencoding/jsonto drop both fields when a real tag name was configured. TheCfield now uses a dedicatedrelation_tag_countconfig option (default"-"). (thanks @jacobmolby) - Fixed generated join alias suffixes using
randInt(), which could produce negative values whenmaphash.Hash.Sum64()overflowedint64(#719). Generated join mods now usebob.NextUniqueInt()instead. (thanks @atzedus) - Fixed
orm.Query.Clone()dropping theScanner, which madeAll/One/Cursor/Eachon a cloned query panic with a nil pointer dereference. (thanks @sandonemaki) - Fixed column_order on
*selectors in sql queries in postgres
New Contributors
- @Leonard013 made their first contribution in #734
Full Changelog: v0.48.0...v0.49.0