Repository navigation
Type the tenant hook and drop sonic for encoding/json - #9
Merged
Merged
Conversation
Config.Tenant returned []any, but tenant columns hold text keys and keel already read the values back as strings. It now returns []string, so the call site says what keel accepts and applications build their keel config without any. The default JSON codec is the standard library's encoding/json instead of sonic. Since Go 1.27 encoding/json runs on the encoding/json/v2 engine with v1's behavior, so the bytes written and the decoding rules are the ones the default always promised. keel no longer depends on sonic, which removes about 100 packages and 1.8 s from a cold build of anything that imports keel. sonic encodes a 1 KB document in 2.0 us against 4.9 us and decodes it in 4.4 us against 9.0 us; Config.JSON still takes any codec for a path that needs it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
emoss08
force-pushed
the
typed-tenant-stdlib-json
branch
from
November 25, 2026 16:08
d0da0f3 to
f633628
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
Config.Tenantreturns[]stringinstead of[]any. Tenant columns hold text keys, and keel already read the values back as strings (scan.go), so the type now says what keel accepts. Applications build their keel config withoutany.encoding/json, not sonic. Since Go 1.27,encoding/jsonruns on theencoding/json/v2engine with v1's behavior, so the bytes written (HTML escaped, map keys sorted) and the decoding rules are the ones the default always promised.jsonnumbercolumns decode with aDecoderusingUseNumber, which rejects trailing data asUnmarshaldoes.Why
keel no longer depends on sonic. Measured on Go 1.27.4:
ConfigStd)encoding/jsonEvery module that imports keel compiles about 100 fewer packages and 1.8 s less from cold. The per-value cost is a few microseconds against a database round trip of hundreds.
Config.JSONstill takes any codec, so a path that needs sonic's speed can set it.Breaking changes
Tenanthook returns[]string:return []any{org, bu}, truebecomesreturn []string{string(org), string(bu)}, true.jsonorjsonbvalue now encodes withencoding/json. The output is byte-identical to the old default (sonic'sencoding/json-compatible mode); setConfig.JSONto keep sonic.keel's minimum Go stays 1.26: the new default works there too, and Go 1.27 only makes it faster.
Checks
gofmt,
go vet(root andbench),keel gen -check,go test -race ./...against Postgres 18, and every benchmark once.Generated with Claude Code