v0.46.0
Added
With()on generated queries as a more ergonomic method to add mods on top of generated queries (thanks @daddz)- Added
Asc()/Desc()/...helpers tosm.OrderCombinedfor PostgreSQL/MySQL (thanks @daddz) - Added SQLite
um.SetCols(columns...)andim.SetCols(columns...)for tuple assignment inUPDATE ... SETandON CONFLICT DO UPDATE SET(.ToExprs(...),.ToRow(...),.ToQuery(...)). SQLite renders(cols) = (exprs...); PostgreSQLToRowstill emitsROW (...). MySQL does not support tuple assignment — use multipleSetColcalls. (thanks @atzedus)
Fixed
- Fixed generated
Setter.Applywrapping all insert values in a singleExpressionFunc, which preventedBeforeInsertHooksand query mods from modifying individual column values viaq.Values.Vals[row][columnIndex]. Base and SQLite codegen templates now emit one expression per column (MySQL already did). Generated SQL is unchanged. (thanks @atzedus) - Fixed generated query mods for combined
UNION/INTERSECT/EXCEPTqueries dropping or misrouting the first operand'sORDER BY/LIMIT/OFFSETinto the combined-result clauses. (thanks @daddz) - Fixed PostgreSQL
um/dmstandalone join mods (InnerJoin,LeftJoin, etc.) applied beforeum.From(...)/dm.Using(...): the join is now preserved and attached to the nextFROM/USINGfrom_item instead of being dropped. (thanks @atzedus) - Fixed/extended PostgreSQL
sm.From(...): it now accepts variadic join chains (sm.From(table, joins...)), and inline joins are merged with already attached standalone joins when replacing the primaryFROMsource. (thanks @atzedus)
Changed
- Moved PostgreSQL
SetColstuple-assignment builder fromdialect/psql/dialect/setcols.goto sharedclause/setcols.go(clause.NewSetCols,clause.SetColsOptions). Dialect wrappers configureToRowviaSetColsOptions.RowPrefix(e.g."ROW"on PostgreSQL). (thanks @atzedus) EQcomparisons passed toSET/ON CONFLICT DO UPDATE SET/MERGE ... UPDATE SET/ MySQLON DUPLICATE KEY UPDATErender without the extra parentheses used inWHERE/ON(e.g.SET "users"."name" = $1vsWHERE ("users"."name" = $1)). (thanks @atzedus)NameAsExpr()on dialectView/Tabletypes (PostgreSQL, SQLite, MySQL) omits a redundantASwhen the alias matches the table name (for exampleFROM "users"instead ofFROM "users" AS "users"). An explicit alias is still emitted when a schema is set at construction (AS "schema.table"). (thanks @atzedus)- Generated slice relationship loaders (
<Parent>Slice.Load<Relationship>) now stitch loaded parents and children in O(N+M) using a map keyed by the join column, instead of the previous O(N×M) nested loop. This greatly speeds up eager-loading and then-loading relationships with many rows on both sides. The map is only used for single-column joins whose key type is comparable with==; composite keys and types with a customcompare_expr(e.g.[]byte) fall back to the original nested loop, so generated behaviour is unchanged. (thanks @sandonemaki)
New Contributors
- @sandonemaki made their first contribution in #706
Full Changelog: v0.45.0...v0.46.0