Repository navigation
Breaking changes
- Go 1.25 is required (was Go 1.20).
dialect.DialectmethodPrintPlaceholderSignis renamed toWritePlaceholder. Custom dialects must rename the method; the built-in MySQL dialect is updated.db:"-"andselectonlynow apply to struct-typed fields. Previously dali recursed into such a field before reading its tag, so its subfields were still selected, inserted or updated. A field taggeddb:"-"is now skipped entirely, and aselectonlystruct field is skipped by?valuesand?set.- MySQL strings and byte slices escape
'as''instead of\'. The doubled quote means a quote both in the default SQL mode and withNO_BACKSLASH_ESCAPES, where\'let a value break out of the literal. Only code that asserts on the generated SQL is affected. Openreturns an error for an unsupported driver instead of panicking.Query.Stringreturnserror: …for a query that fails to expand instead of panicking.
Renames (old names kept as deprecated aliases)
Translator→Expander, andTranslator.Translate→Expander.Expand.dialect.Dialect→dialect.Escaper.
Existing code, including Marshaler implementations taking a Translator, keeps compiling.
New
-
DB.AddMiddlewareFuncadds a middleware on top of those already set, instead of replacing them asSetMiddlewareFuncdoes. -
Errors from a
driver.Valueror aMarshalerare wrapped with%w, soerrors.Isanderrors.Assee them. -
dalivet, a
go vet-style analyzer for dali, released as its own module (dalivet/v0.1.0). Building it needs Go 1.26 or newer. It reports non-constant query strings, placeholder/argument mismatches, wrong destinations ofOne,AllandScanAllRows, slices passed to?...or?values...without a length check, and unknowndbtag options:go install github.com/mibk/dali/dalivet/cmd/dalivet@latest go vet -vettool=$(which dalivet) ./...
Fixes
- Fields of a struct nested three levels deep (embedded or a named struct field) all got the index of the struct’s last field, so every one of them was loaded into, or inserted from, that last field.
Performance
- Derived column lists are cached per type, and escaping identifiers no longer allocates a replacer per call.
Upcoming
- dali ignores unknown
dbtag options today (db:"id,readonly"still inserts the field). A future version will reject them at run time; run dalivet to find them now.
Notes
- An empty or nil slice passed to
?...is an error, as in v0.5. Check the length before running the query. - dali escapes values itself rather than sending bind parameters. It is safe on MySQL/MariaDB connections using a UTF-8 character set; see the README for the caveats about multi-byte charsets such as GBK and
NO_BACKSLASH_ESCAPES.