Compatibility
ant hasn't reached 1.0, so anything can change between releases. Each release's release notes list its breaking changes.
Go
ant needs Go 1.27 or later, because its API uses generic methods. Each release supports the two newest Go versions.
| Feature | Since | Used for |
|---|---|---|
iter.Seq2 | Go 1.23 | Streaming with Each |
new(expr) | Go 1.26 | Nullable values, as in user.Bio = new("text") |
| Generic methods | Go 1.27 | Join[J], Include[R], Select[R] in fluent chains |
| Field selectors as struct literal keys | Go 1.27 | User{ID: 1} for fields promoted from ant.Base |
Databases
| Database | Status |
|---|---|
| PostgreSQL 13 to 18 | Supported: the whole suite passes on each, as of 2026-11-01 |
| MySQL 8.4, MariaDB 11.8, SQLite (modernc 1.61), SQL Server 2022 | Queries and writes: the conformance and concurrency suites pass. No migrations |
MERGE needs PostgreSQL 15. Everything else works from 13. PostgreSQL 12 and older are out of support upstream and untested here. The comments in each dialect name the oldest versions expected to work, from their documentation, but only the versions above have been run.
ant runs on the pgx driver through database/sql. pgxext needs pgx. See databases for what each database lacks.
Breaking changes so far
The latest release is v0.3.2. Before it came v0.1.0, v0.2.0, v0.3.0 and v0.3.1.
v0.3.2
No exported name changed or went away. It adds ant.ErrNestedIsolation, pgxext.ErrInTx, metrics.Operation and JSON decoding for secure.Value. Some behaviour changed, mostly where ant used to misread something without a word and now refuses it:
ant.Openrefuses a MySQL or MariaDB DSN withoutparseTime=true, aversionfield that is not a signed integer, and two models that reach one table by convention.- Two relations to the same model, guessed onto one foreign key, are
ant.ErrNoForeignKeyuntil one names its key. - A negative
LimitorOffsetis an error, andant.SQLorant.SQLCondwith arguments needs one per?.Rawrefuses two result columns for one field. Afterreturnsant.ErrCursorfor an ordering column that can holdNULL, and for a query with its ownLimitorOffset.Page,ChunkandChunkByKeyread inside a query'sLimitandOffset.Upsertruns the validation rules,Validate,BeforeInsertandAfterInsert. A soft delete andRestorestampUpdatedAtand move a version on.- Options on a
Txnested in another hold, so a nestedant.ReadOnly()isant.ErrUnsupportedoff PostgreSQL.pgxext.CopyandBatch.Sendrefuse a transaction's context. - A time read from the database is in UTC on PostgreSQL too, and a
postgres.Arraywith aNULLelement is an error.
v0.3.1
No breaking changes. It cuts allocations and time on reads, tracking, saves and inserts, with the same API. The dialect and qb packages gain helpers for a dialect to write into ant's render buffer.
v0.3.0
No exported name changed, but some behaviour did:
ant.Col(&f).Eq(nil)and.Ne(nil)renderIS NULLandIS NOT NULL, asant.Eqandant.Nealready did. They used to bind the nil and match no rows, so a query that relied on that can now return rows.- A bulk
Update, an upsert'sDoUpdateorSet, a merge'sWhenMatchedandUpdateManyrefuse an immutable, readonly or computed field with an error naming it, asSaveChangesalways did. - A migration that changes a column's type no longer casts with
USINGwhere PostgreSQL has a cast of its own, so a value too long for the new type fails the migration instead of being cut short. - A
Txretry forgets what the failed run loaded or added, and a save afterMarkModifiedstampsUpdatedAt.
The docs and examples now name a probe after its model in the plural, Users = ant.Fields[User](), instead of U. That is a naming convention, not an API change: old code still compiles.
v0.2.0
v0.2.0 made the first breaking change: the helpers that read or mark the change tracker now take a context.Context, and those that returned nothing now return an error.
| Before | v0.2.0 |
|---|---|
ant.Add(db, e), Attach, Remove, MarkModified | ant.Add(ctx, db, e), and so on, returning error as before |
ant.Detach(db, e) | ant.Detach(ctx, db, e) error |
ant.TrackGraph(db, root, decide) | ant.TrackGraph(ctx, db, root, decide) |
ant.Tracked[T](db) | ant.Tracked[T](ctx, db) ([]*T, error) |
ant.Entry(db, e) | ant.Entry(ctx, db, e) (*EntityEntry[T], error) |
db.HasChanges() | db.HasChanges(ctx) (bool, error) |
db.ClearTracked() | db.ClearTracked(ctx) error |
db.DebugTracked() | db.DebugTracked(ctx) (string, error) |
The context lets ant tell a hook that runs inside an operation from another goroutine using the same tracking context, which gets ErrConcurrentUse. Pass the context your hook or handler received. A call made with an unrelated context while another operation holds the tracker is refused.
go build ./... finds every call to change.
From 1.0
ant will follow semantic versioning: patch releases fix bugs, minor releases add to the API and change nothing that exists, and major releases can break things, with notes on how to move.
The API is:
- Every exported name in the public packages, which a test keeps a record of in
docs/api.txt. - The behaviour the documentation and
tests/featuresdescribe. - The migration file format, and the history table.
The API isn't:
- Anything under
internal. - The exact SQL ant writes, which can change as long as it means the same.
- The text of error messages. Match errors with
errors.Is. - The
dialectandqbpackages, until a dialect outside this module exists to settle them.
Files that outlive a release
Migrations and snapshots stay readable. A snapshot records its format, and a newer format is refused with a clear error, not misread. The history table only gains columns.
Upgrade a project
- Read the release notes for each version you cross.
- Update the module:
go get github.com/skudra-go/ant@latest. - Run
go build ./.... A renamed or changed API fails here. - Run your tests against a real database.
- Run
go run ./cmd/migrate check. A release can change how a model maps to a schema; this shows it. - Run
go run ./cmd/migrate driftagainst a staging database.