Remove ContextCreator from Database interface for compatibility with external SQL packages - #7
Merged
Conversation
Co-authored-by: ziflex <1607148+ziflex@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove
Remove ContextCreator from Database interface for compatibility with external SQL packages
Aug 31, 2025
ContextCreator from Database interface in order to make it compatible with other sql packages like sqlx.
ziflex
approved these changes
Aug 31, 2025
ziflex
marked this pull request as ready for review
August 31, 2025 16:51
ziflex
approved these changes
Aug 31, 2025
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.
The
Databaseinterface previously embeddedContextCreator, making it incompatible with external SQL packages likesqlxthat don't implement aContext(context.Context) Contextmethod. This prevented users from using dbx with existing database abstractions.Problem
External packages like
sqlxprovide their own database abstractions that implement the core SQL operations but don't have dbx-specific methods likeContext(). This made it impossible to use them with dbx's transaction system:Solution
This PR removes
ContextCreatorfrom the coreDatabaseinterface while maintaining full backward compatibility:Core Changes
ContextCreator, making it compatible with any SQL packageNewContextFromandNewDatabaseContextwork with any Database implementationUsage Examples
External Package Compatibility (now works):
Existing dbx Usage (unchanged):
Flexible Context Creation:
Backward Compatibility
All existing code continues to work without modification. The
New()function returnsDatabaseWithContext(which embeds bothDatabaseandContextCreator), so existing users retain theContext()method while new users can implement just the minimalDatabaseinterface.Testing
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.