Repository navigation
Releases
Releases · kiplagatcollins/fusion-orm
v0.4.0
Fixed
- Composite primary keys no longer bind, order, or paginate by the first key column alone (audit groups D/Q):
- Scalar id conditions (
First/Find/Take/Last/Delete(&m{}, 42)) on a composite-key model returnErrInvalidValueinstead of matching every row sharingPKs[0]. Single-key behavior is unchanged. Savematches updates on the full key tuple (a = ? AND b = ?) and inserts when any key field is zero;FirstOrCreatetreats a row as persisted only when the whole tuple is set.First/Lastorder by the full key tuple, making results deterministic when the first key column ties.FindInBatchespaginates composite keys with row-value keyset comparison ((a, b) > (?, ?) ORDER BY a, b), gated on the newfeature.RowValuesflag (declared by the SQLite and PostgreSQL dialects); dialects without it get a clear unsupported-feature error.- SQLite
LastInsertIDbackfill no longer overwrites client-assigned composite key fields with the rowid. - Relation inference fails loudly instead of guessing: belongs-to onto a composite-key table requires an explicit
referencescolumn; has-one/has-many/many2many on a composite-key side are rejected at parse time (single-column relations onto composite tables via explicit tags keep working).
- Scalar id conditions (
Performance
Statementis embedded by value inDB: every chain hop costs one allocation instead of two.- The 16 canonical clause names live in an inline slot array + presence bitmask; the
Clausesmap andOrderslice now exist only for custom (plugin) clause names.AddClause/RemoveClause/Clauseandcloneare allocation-free for standard clauses (Countno longer allocates to strip ORDER BY). - Association callbacks bail out immediately for models with no relations, and no longer format a discarded error when
Destis nil (Updatehad been paying ~6 allocs/op on this path). logger.Tracer(optional interface implemented by both built-in loggers): the query path checksWouldTracebefore allocating the trace closure, so gated loggers pay nothing per statement.BuildClausesreuses the previous build's buffer on rebuilds.- Measured (benchcmp, in-memory SQLite, interleaved n=10): allocation geomean 97/op vs bun 126 (+29%) and gorm 249 (+155%). Time geomean leads bun by ~8% and gorm by ~47% on this run.
Added
feature.RowValuesdialect flag (SQLite, PostgreSQL).
v0.3.1
Performance (allocation-reduction pass)
- Single-row Create is no longer wrapped in a synthetic BEGIN/COMMIT when the write is provably one statement (no relations, no hooks, no multi-chunk batch) — halves the common-case write path.
- Scan loop: amortized slice growth (
appendOne) replacesreflect.Append+Set;time.Timevalues scan via typed assignment instead of boxing throughreflect.ValueOf; RETURNING integer ids scan typed rather than throughany. - Per-row hot paths: insert SQL built directly (no intermediate
clause.Values/Expression), timestamps set with typed assignment, hook presence checked via a precomputed flag (no per-rowMethodByNamereflection),ON CONFLICTtargets carry nostrings.Splitper build. - Chain/finisher paths use copy-on-append condition slices, a shared
COUNT(*)select,Statement.SkipTimestampsinstead of a sync.Map setting, and schema lookup byreflect.Typewithout instantiating a throwaway model. Callback execution bookkeeping uses an indexed slice instead of a map. - Measured (in-memory SQLite, interleaved A/B/C runs): fusion geomean now leads bun by ~8% and gorm by ~28% across 11 operations; allocs/op down 30-97% per operation (Pluck 2067→57, FindAll 9798→4797, Create 86→46).
v0.3.0
Added
AutoMigratecreates many-to-many junction tables as two-column, composite-primary-key tables (GORM #7365/#7006 class).clause.OnConflict.UpdateAllupserts every non-primary-key column with the primary key as the conflict target.- Audit of the 450-issue gorm backlog:
docs/AUDIT.md(classes A–Q, verdicts withfile:lineevidence) plus a promoted 18-test regression suite and the fix-phase design record.
Changed
- Explicit
index:/unique:tag values render as<name>_<table>inCREATE INDEX, so two tables can declare the same index name; generated default names are unchanged (GORM #7346 class). Saveon a slice dispatches element-wise by primary key (insert new rows, update rows with a set PK) instead of inserting everything (GORM #7540).- Creating an association child whose primary key is set updates the existing row instead of inserting a duplicate (GORM #6119).
Row()on a build error returns a failing sentinel row instead ofnil(which panicked inScan); the build error surfaces on the chain node'sError(GORM #7575).OnConflictrenders a targetlessON CONFLICTwithout parentheses and never emitsON CONFLICT ()or a danglingDO UPDATE SET.
Fixed
- Transaction finalizers (commit/rollback) run after errors and panics, so implicit transactions are always released (GORM #7897/#7908/#7459).
- The
ErrMissingWhereClauseguard now runs before soft-delete rewriting — global soft deletes error instead of updating every row (GORM #6338); the soft-delete filter is ANDed across OR groups (GORM #6998/#5652) and filters inline relation joins (GORM #7385). clause.OrrendersORwith correct precedence/parenthesization; map conditions produce stable, key-sorted SQL (GORM #5652/#7351).CountstripsORDER BYbefore executing (GORM #7516).- Many-to-many append skips already-linked pairs (GORM #5579).
- Prepared-statement cache: statements handed to callers are refcounted and can no longer be closed under them by concurrent eviction (GORM #7831);
preparedPoolforwardsPing(GORM #6181);AutoMigrateinvalidates cached statements after DDL (GORM #7255). - Errors raised inside
Scopespropagate to the finisher chain (GORM #6283). - Composite-primary-key tables no longer emit two
PRIMARY KEYclauses inCREATE TABLE.
v0.2.0
Added
- gorm-parity base models:
fusion.Model(autoincrementuint64ID) andfusion.UUIDModel(UUIDv7 ID generated at create time), both withCreatedAt/UpdatedAtand soft-deleteDeletedAt. type:uuidcolumn type: nativeuuidon PostgreSQL,TEXTon SQLite.
v0.1.1
Fixed
AutoMigratenow preserves non-constant column defaults (e.g.fusion:"default:CURRENT_TIMESTAMP") when adding columns to existing tables on dialects that reject them inALTER TABLE ADD COLUMN(SQLite), by rebuilding the table with the full desired schema and copying rows across.
v0.1.0
Initial release of fusion-orm.
Added
- Core session layer, dialect framework, and cached schema reflection.
- Clause builders, statement registry, scanning engine, and CRUD callbacks.
- Batched
Preload, inlineJoins, association API, and association callbacks. G[T]generics facade, soft delete, prepared statements, error translation, migrations, and query hooks.- README, runnable examples, error-path tests, and CI with vet/lint/race/bench.
Changed
- Dialect-specific behavior is selected through named feature flags; no dialect-name string comparisons remain in library code.