sqlex is a modern SQL extension library for Go, built as a drop-in modernization of jmoiron/sqlx. It inherits the core sqlx APIs you already know, while fixing long-standing issues and adding new capabilities for Go 1.21+.
Repo: https://github.com/go-sqlex/sqlex
Why another sqlx fork?
jmoiron/sqlx has been the go-to SQL extension library for years, but maintenance has slowed significantly. There are numerous open issues — especially around the SQL lexer — that haven’t been addressed for a long time. Things like:
-
Strings or comments containing
:being misparsed as named parameters -
Edge cases where
Rebindproduces unexpected output -
Manual
sqlx.In+Rebinddance required for every IN query
These aren’t theoretical issues — they’re real pain points that teams hit in production.
What sqlex does differently
-
Auto IN expansion — write
WHERE id IN (?)with a slice, it just works. No moresqlx.In+Rebindboilerplate. -
Pluggable Hooks — intercept SQL execution before/after for logging, metrics, tracing, etc.
-
Auto placeholder conversion — use
?everywhere in your code, sqlex handles$1,@p1, etc. behind the scenes per database. -
Generic JSON support —
JsonValue[T]maps JSON columns directly to strong types. -
API modernization — unified method naming and parameter ordering across
Get/Select/NamedExec/NamedQuery, reducing learning curve and misuse. -
Go 1.21+ — uses
any, modern error handling, actively maintained.
Migration from sqlx
Since sqlex inherits the core sqlx API design, migration is straightforward. Most projects can switch by updating import paths and initialization. A detailed migration guide is available in the README.
Project status
sqlex is actively maintained, with v1.5.1 already released and validated in internal production use. Issues, PRs, and feedback are all welcome.