All notable changes to github.com/ubgo/sqlb are documented here. The format follows Keep a Changelog, and versioning is SemVer with the pre-GA convention that v0.x may break.
- SQLite spells the portable timestamp and date types
TIMESTAMPandDATE, notTEXT. The storage is text either way, but the modernc SQLite driver decodes a column declaredTIMESTAMPorDATEinto atime.Timeand returns aTEXTone as a string, so aCol[time.Time]created byddl.Column(or bycontrib/migrate'sCreateTablefrom aschema.TypeTimestampcolumn) could be written and never scanned back.schema.EngineType("sqlite", …), theddlbuilders andcontrib/migrateall read the one table. Upgrading: a SQLite database created by an earlier release's DDL still hasTEXTcolumns, andsqlb vet'sCompareTables/CheckTablesnow report each as a type difference; declare such a column withddl.RawType[string]("TEXT")and read it as a string, or move it with a table rebuild. ASTRICTtable accepts neither new spelling and needsRawType("TEXT")too.
-
contrib/migratev0.1.3: a library can read its old ledger inside the adoption, on the ledger's connection and under its lock.Adopt'sRantakes no connection and returns no error, so a library that must read its old ledger table to answer it read that table first, on a connection of its own. On SQLite, two processes starting on a fresh file withjournal_mode(WAL)in the DSN then failed that read withdatabase is lockedin about one round in four, because the other process was converting the file to WAL and only the ledger's own connection waits that out.Ledger.AdoptPreparedandAdoptPreparedDBtake amigrate.PrepareRan,func(ctx, conn) (Ran, error), called once with the ledger's connection after the lock is taken and the ledger read, before any migration is judged; its error ends the call with nothing recorded and is returned wrapped, soerrors.Isfinds the caller's own error. Two processes on 200 fresh WAL files, each reading its old ledger this way, now succeed every time (the same read beforeAdoptfailed in 44 of 200 rounds).AdoptandAdoptDBare unchanged. The guide's section Moving an existing migration history onto the ledger now reads the old ledger this way. -
contrib/migrate: a library with a migration history of its own can move onto the ledger, and can write the ledger's statements into an offline script. A library that kept its own ledger table could not take its users' databases over, because the only way in wasApply, which re-ran migrations that had already run (anADD COLUMNfails the second time), and it could not offer an offline script because the ledger's own DDL and row were unexported.Ledger.AdoptandAdoptDBrecord migrations as applied without running them, with the checksumsApplycomputes, in one transaction under the ledger's lock, idempotently, refusing an edited migration withErrChecksumMismatchand honouringRefuseUnknown; amigrate.Rancallback says which of the known migrations ran and when, so the usual flow is to read the old ledger, adopt what it lists, thenApplythe rest.Ledger.Script,TableScriptandRecordStatementreturn the ledger'sCREATE TABLE, each migration's statements and theINSERTthat records it, built by the codeApplyruns, so a script run by hand leaves a database on whichApplyapplies nothing.Ledger.WithClockinjects the time recorded inapplied_at, for tests and reproducible scripts; the default staystime.Now.Apply's behaviour and every existing name are unchanged.contrib/migratenow requires the root module atv0.1.3, the first tagged root its own tests pass against (they expect SQLite'sTIMESTAMPspelling). The guide's new section is Moving an existing migration history onto the ledger. -
A table's description can say how an index sorts and whether it is partial, and
sqlb vetchecks both. A library that createdCREATE INDEX … WHERE record_path IS NULLor(account_id, started_at DESC)with the typed builder could not list that index in its description: the live check reported a listed partial index as missing and compared a descending index equal to an ascending one.schema.IndexgainsOrders(aschema.KeyOrderper key:DirectionAscending/Descending,NullsOrderNullsFirst/NullsLast) andWhere;Describe()onpg.CreateIndexandsqlite.CreateIndexreturns the index'sschema.Indexwith both filled from what the builder was given (an expression key isddl.ErrNotDescribable), andsqlite.UniqueOnwith a direction describes it.contrib/vet's readers now report every key's direction (Postgres with NULLS placement, SQLite, MySQL) and Postgres and SQLite partial indexes with their predicate, andCompareKeys/CheckTablesreport a difference as a typed finding,Finding.Kindvet.FindingIndexOrderorvet.FindingIndexPredicate. A predicate is compared by a normal form and, on Postgres, by the engine's own canonical text of both sides (a temporary view in a rolled-back transaction); a pair that cannot be compared is the warningvet.FindingIndexPredicateNotCompared, never a pass. The rule and its limits are in thecontrib/vetREADME. The widgets example gains a partial owner index in migration 0003, described by its ownCREATE INDEX.Compatibility: an index described without
Ordersis not judged on order and one withoutWhereis judged as before. Two behaviours change: a partial index in the database is no longer skipped, so a declared full index whose only database match over the same columns is partial is now reported as "partial in the database" instead of "not in the database", and an undeclared partial unique index is now the same warning as any undeclared unique index.Findingandschema.Indexgain fields, so an unkeyed struct literal of either no longer compiles. Code that hands its ownIndexElementtopg.CreateIndexorsqlite.CreateIndexbuilds as before, and itsDescribeisddl.ErrNotDescribable. -
examples/prefixed/widgetsanddocs/declare-once.md: a library whose tables are written once under a run-time prefix, with its declaration, hand-written numbered migrations on thecontrib/migrateledger,vet.CheckTablesagainst the declaration, andON CONFLICT,RETURNINGandFOR UPDATEqueries, executed on SQLite and Postgres 17 incontrib/vet/enginetest, including adopting a database an earlier release created withCREATE TABLE IF NOT EXISTSstrings. The page ends with the recipe for converting such a module.
contrib/migrate/v0.1.1, contrib/structbind/v0.1.1, contrib/driver-sqlite/v0.1.1, contrib/driver-pgx/v0.1.1, contrib/driver-mysql/v0.1.1, contrib/vet/v0.1.2 and the new contrib/vet/cmd/sqlb module. No change to any library's Go code (#4).
- A released module now requires only what its library code imports. The tests that open a database moved to a never-released
enginetestmodule beside each module (internal: truein its.volt.yml):contrib/migrate: its tests imported the pgx, MySQL and SQLite drivers while itsgo.modlisted none of them, sogo mod tidyin any module importing migrate added all three drivers to that module'sgo.mod. migrate now requires only the core.contrib/structbindno longer requiresmodernc.org/sqlite; it requires only the core.contrib/driver-sqlite,contrib/driver-pgxandcontrib/driver-mysqlno longer require the core, which only their conformance tests used; each requires only its database driver.contrib/vetno longer requires any database driver. Thesqlbcommand, which opens a database forsqlb vet --dsn, is its own module,github.com/ubgo/sqlb/contrib/vet/cmd/sqlb, and carries the three drivers;go install github.com/ubgo/sqlb/contrib/vet/cmd/sqlb@latestinstalls it as before.
scripts/covmerge.pyrun inside anenginetestmodule measures the module it sits in, and the CI coverage floor forcontrib/driver-sqliteruns incontrib/driver-sqlite/enginetest.
0.1.1 - 2026-10-11
install.shandinstall.ps1at the repository root, generated by volt, install the prebuiltsqlbandsqlbvetbinaries for macOS, Linux and Windows:curl -fsSL https://raw.githubusercontent.com/ubgo/sqlb/main/install.sh | sh. ThesqlbCLI's release archives carrysqlbvetbeside it fromsqlb/v0.1.1.
- Releases are cut with volt: one tag stream per module and CLI, a manual release workflow that republishes an existing tag with
volt release --from-tag, and aciworkflow runningvolt ci. The hand-taggingtask release:*tasks are gone. The core andcontrib/vetare released asv0.1.1andcontrib/vet/v0.1.1with no change to their Go code; thesqlbCLI assqlb/v0.1.1.
0.1.0 - 2026-10-11
docs/architecture.md: the layer plan. One module per layer, the rule that every layer compiles without the ones above it, why one module per file is impossible given the current import cycles, the committed workspace, the zero-cost facade through generic type aliases, and the order the work has to happen in. Nothing in it is built; it is the target shape.
- The core builder: tables with typed columns,
Expr[T],Param,Literal,NullableandAssertNotNull, the predicate set,BindandBindings. Selectwith joins, CTEs including recursive ones, set operations, window functions with frames, aggregates, subqueries,GROUP BYandHAVING, ordering,LIMITandOFFSET.Insert,UpdateandDelete, withRETURNINGwhere the dialect has it.- Dialects for Postgres, SQLite and ClickHouse, all three in the core beside each other, capability interfaces for
RETURNING, insert aliasing and named parameters, andErrUnsupportedDialectso an engine construct fails atBuild. Clauseslots,Optionfunctions and the typed door, the four mechanisms a library uses to let its callers extend a query it owns.SlotAfterInsertsits between the INSERT keyword and INTO, which is where SQLite spellsOR REPLACEand no other engine spells anything.pg: JSONB and SQL/JSON, arrays, ranges and multiranges, text and full-text search,DISTINCT ON, locking clauses,ON CONFLICT,MERGE,LATERAL, recursive search and cycle clauses, session and catalogue functions.pgextension sub-packages, one perCREATE EXTENSION:vector,trgm,fuzzy,ltree,crypto,earth,unaccent, andpostgisas the template. Each has a README and a guard test, and each is built from the guarded constructorspgexports, so adding an extension never editspg.pg/vector: the full pgvector surface, four vector types, six distance operators and their function forms, the utility functions, element-wise aggregates and arithmetic, casts, typed parameters and the query-time settings, with the pgvector README covered query by query.sqlite: what only SQLite has.INSERT OR REPLACEand its four siblings, theON CONFLICTupsert withExcluded, the JSON1 extension includingjson_eachandjson_treeas sources, FTS5 search withrank,bm25,highlightandsnippet, the time-modifier family,rowidand the session counters, and theINDEXED BYplanner hints. Every one of its 70 helpers is executed against a real database bycontrib/driver-sqlite, which makes it the only engine package here whose SQL is proven rather than asserted.ch:PREWHERE,FINAL,SAMPLE,ARRAY JOIN,LIMIT BY, statement settings, and ClickHouse aggregate and time functions.- Engine-package building blocks in the core:
EngineGuard,EngineExpr,EnginePred,EngineBinOp,EngineBinPred,EngineFn,EngineLit,EngineRaw,EngineClause,EngineSource,EngineListandEngineQuoteLit. The guard rule that makes an engine construct fail closed under another dialect now lives in one place instead of being copied intopg,sqliteandch, and a community package in another repository builds a dialect and its constructs with the same guarantees. ErrUnknownSlot. A clause aimed at a slot a statement does not render is an error naming the slot, where it used to be dropped silently.Slot.Stringnames every slot, and a test walksSlotValuesasserting each is either rendered by some statement or rejected.Join.Clauses, for a per-table hint such as SQLite'sINDEXED BY, MySQL'sUSE INDEXor T-SQL'sWITH (NOLOCK). It is the one position a slot cannot name, because there is one per join rather than one per statement; putting such a hint in a statement slot bound it to the driving table instead.- The slot set is complete rather than minimal: a slot at every boundary the renderer emits, so every position in a statement is reachable from a package in another repository.
SlotAfterColumns,SlotAfterWhere,SlotAfterHavingandSlotAfterVerbjoin the set;SlotAfterTargetnow covers INSERT and UPDATE as well as DELETE; and UPDATE and DELETE renderSlotTail, which they previously did not.SlotAfterGroupByis MySQL'sWITH ROLLUPandSlotBeforeOrderisQUALIFY, which DuckDB, Snowflake and BigQuery use to filter on a window result. ErrQueryInUseandNewQuery. A Query holds pointers into the caller's variables, so sharing one across goroutines was a data race that interleaved rows silently;OneandEachnow refuse an overlapping execution instead. The guard belongs to the builder, so hoisting a builder is caught as well as hoisting a query.NewQuerylets an engine package rendering its own statement kind, such as pg's MERGE, get the same check instead of assembling a bare struct literal.sqlbtest: the shared conformance suite every driver integration runs against a real database.contrib/migrate:InstallandPlanorder several packages' tables by foreign key,Executeruns addl.Scripthonouring its flags, and an opt-inLedgerapplies checksummed migrations once each under anEngineLock.Ledger.AppliedandAppliedDBread the ledger back oldest first, an empty list when its table is missing;RefuseUnknownmakesApplyfail withErrUnknownMigrationon a recorded migration it was not given; and on SQLite the ledger begins its transactionsBEGIN IMMEDIATEand retries the connection open,BEGINandCOMMITon busy, so two deploys on one file wait for each other instead of failing withSQLITE_BUSY, ending inErrLockedat the context's deadline orDefaultLockWait.contrib/driver-sqlite: the first contrib module, opening SQLite with the pragmas a library-owned schema needs, and running the conformance suite.examples/: the compile-checked catalogues, and the negative build that fails if deliberately wrong code ever compiles.