Repository navigation
luima now runs on bun v1.2.18 with pgdriver, where every release through v0.5.0 ran on go-pg v10. luima's signatures named go-pg's types, so this release breaks the public API. The break is kept to what the switch forces: every function keeps its name, its parameters' meaning and its absence contract, and server/ is unchanged.
It also closes a gap that was open in every earlier release: luimaerr.PresentError did not redact what resolvers report.
Upgrading
The compiler finds most of the migration, and the changelog maps each break in one line:
*pg.DB→*bun.DB, andorm.DB→bun.IDBin the five CRUD helpers.- One option-closure type per statement (
*bun.SelectQueryforGet/List,*bun.InsertQuery,*bun.UpdateQuery,*bun.DeleteQuery) in place offunc(*orm.Query) *orm.Query. pg:"…"tags →bun:"…",pg.ErrNoRows→sql.ErrNoRows,HealthCheck: db.Ping→db.PingContext.ConnectWith's tune func andStatementTimeoutnow take a*pgdriver.Config.
Two changes compile and then misbehave. Read both before deploying against a table that already holds rows:
- The table name comes only from an embedded
bun.BaseModel. bun silently skips go-pg'stableName struct{}field. A model that keeps it still compiles, and every query then goes to the pluralized type name:users, notapp_users. - A zero-valued field is stored as its zero value. go-pg sent
DEFAULTorNULL; bun sends'',0,FALSEor the zero time. This affectsDEFAULT now()columns, identity and generated columns, and nil,arrayslices.docs/gotchas.md#27 lists the tag each one needs (,nullzero,,autoincrement,,scanonly).
Runtime differences worth knowing:
- A cancelled context no longer stops the query on the server. pgdriver sends no CancelRequest, so
StatementTimeoutis the only bound Postgres enforces. - pgdriver's socket timeouts cap every statement: 10s read, 5s write. Keep
statement_timeoutbelow both. - Unknown DSN parameters become
SETstatements on each connection. A misspelled one fails at connect time instead of while parsing. db.Connectrefuses a DSN whose credentials an unescaped/,?or#cuts short. Percent-encode/ ? # %in the user and password.
Security
PresentErrornow redacts resolver errors. gqlgen wraps a resolver's error in a*gqlerror.Errorbefore the presenter sees it, and luima passed that wrapper through. Raw driver text, such as a constraint name orrelation … does not exist, reached clients with noextensions.code. Now any error that is neither a*luimaerr.CustomErrornor one of gqlgen's own errors about the request is logged. The client getsinternal server errorwithINTERNAL_SERVER_ERROR. To send a message to a client, return a*luimaerr.CustomError.DisableIntrospectionrefuses the whole operation before any field runs. The client getsINTROSPECTION_DISABLED, and no log line is written.db.Connecterrors no longer quote part of the password. In every earlier release, an unescaped/,?or#in the password could leak its opening characters into the parse error.
Fixed
- A negative
StatementTimeoutnow disables the bound, as documented. It used to make every new connection fail.
See the changelog for the details behind every line here, and docs/gotchas.md #38–#40 for the new failure modes.