Repository navigation
WithSchemaName: name the schema of the published changes - #55
Merged
Merged
Conversation
The changes of every database are published with the schema main, so two databases whose tables have the same names, which publish to one broadcaster, can't be told apart. WithSchemaName names it, such as webhook. Attached databases' changes keep their names, and a failed statement's rows are still checked in main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Schema renaming occurs before publication filtering, causing FTS5 internal shadow-table changes to be published when WithSchemaName is used, violating the existing filtering contract.
1 open issue
What changed in this PR
Adds configurable schema names to SQLite change notifications so databases with identically named tables can share a broadcaster and remain distinguishable.
Changes:
- Introduces
WithSchemaNameand validates names as identifiers. - Applies the configured name to main-database notifications while leaving attached database names unchanged.
- Documents the option and tests row changes, failed statements, table-level notifications, and invalid names.
| File | Description |
|---|---|
| README.md | Documents schema naming for shared broadcasters. |
| opts.go | Adds Options.Schema and WithSchemaName validation. |
| ncruces/changes.go | Applies the configured schema name when collapsing changes. |
| ncruces/changes_test.go | Tests renamed notifications and invalid schema names. |
Review effort: Balanced
|
Coverage for this change: 90.8% |
…re checked Renaming in collapse made isPublished look up the table in the renamed schema, which it couldn't find, so FTS5's shadow tables were published. The change keeps its database's name until it's published. 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.

WithBroadcasterpublishes every change withSchema: "main", the database's name. So two databases whose tables have the same names, publishing to one broadcaster, can't be told apart. go-llm's webhook store, withwebhookandcalltables, will share the server's broadcaster with other stores.sqlite.WithSchemaName(name)publishes the main database's changes under that name instead:Options.Schema, set byWithSchemaName, must be an identifier.collapse), not when rows are recorded. After a failed statement in a transaction, its rows are still checked againstmain, under the database's real name.