Open two methods of UmbracoDatabaseFactory for External Packages (closes #21606)#21589
Open two methods of UmbracoDatabaseFactory for External Packages (closes #21606)#21589idseefeld wants to merge 24 commits intoumbraco:mainfrom
Conversation
refactor new extensions into another file
…xProvider-methods
…xProvider-methods
…ethods' of https://github.com/idseefeld/Umbraco-CMS into v173/21451-quote-raw-sql-names-with-SqlSyntaxProvider-methods
…n UmbracoDatabaseFactory
|
Hi there @idseefeld, thank you for this contribution! 👍 While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
There was a problem hiding this comment.
Pull request overview
This PR exposes previously private extension points in UmbracoDatabaseFactory to enable plugin authors to access the resolved DbProviderFactory and override database instance creation.
Changes:
- Changed
DbProviderFactoryfromprivatetoprotected. - Changed
CreateDatabaseInstance()fromprivatetoprotected virtual.
Comments suppressed due to low confidence (1)
src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs:113
DbProviderFactorywas changed fromprivatetoprotected, but it is still non-virtual. If the goal is to make it overridable by plugins (as per the PR description), derived factories cannot override this member (hiding withnewwon’t affect calls inside the base class). Consider making itprotected virtual, or adjust the PR description to state that it’s only being made accessible (not overridable).
protected DbProviderFactory? DbProviderFactory
{
get
{
if (_dbProviderFactory == null)
{
_dbProviderFactory = string.IsNullOrWhiteSpace(ProviderName)
? null
: _dbProviderFactoryCreator.CreateFactory(ProviderName);
}
return _dbProviderFactory;
}
}
|
Can you expand on why you need these changes please @idseefeld? Maybe share a sample of your code where you show why you need to be able to access this property or override this method. |
|
@AndyButland I use a method override for This is the whole factory class source: This all is related to PR #21590 because But I figured out this approach some time ago and will have a look into it again. I'll check whether this PR and PS #21590 can be avoided. |
|
Yes, I was hoping you'd mostly be able to follow the same pattern as the existing projects in core for SQL Server ( |
|
Sorry, but I could not find another solution. The NPoco project is not well maintained and PRs get not handled in time. The tests are mostly broken and the PostgreSQL handling is not compatible with Umbraco. |
This PR changes two private methods of
UmbracoDatabaseFactoryto make them accessible and overridable by packages.