Repository navigation
Set tenant settings for row-level security with BEGIN - #10
Merged
Merged
Conversation
Config.TenantSettings names run-time parameters keel sets, transaction-local, to the tenant's values at the start of every transaction a tenant scope opens, in the same round trip as BEGIN. It is what applications wrote OnBegin for to back keel's scoping with Postgres row-level security, without a callback, an []any of arguments or a result-cache Key: the settings follow the scope. System scopes and unscoped work set nothing, and Open refuses a list that does not match the tenant columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.TenantSettingsnames run-time parameters keel sets, transaction-local, to the tenant's values at the start of every transaction a tenant scope opens:BEGINin the same round trip, for explicit and implicit transactions.Openrefuses a list whose length differs fromTenantColumns.Why
Backing keel's scoping with row-level security is the main reason applications write
OnBegin, and doing it there takes a callback, a[]anyof arguments and, with the result cache, aKeyfunction. The settings depend only on the scope, which keel already has and the cache already keys on, so keel can set them itself.OnBeginremains for settings that depend on more than the tenant.Not breaking: a config without
TenantSettingsbehaves as before.Checks
gofmt,
go vet(root andbench),keel gen -check,go test -race ./...against Postgres 18. New tests cover settings in implicit,WriteandReadtransactions in one round trip, a second tenant, a system scope, and the length check.Generated with Claude Code